How to get entire code inside Python Script

I’m trying to get the code inside a component as output.
For example, in Grasshopper, it’d be using ghenv.Component.Code. What would be the equivalent way of doing it in Dynamo?

Also, are there hidden variables in Dynamo similar to grasshopper’s ghenv, ghdoc, etc., Dynamo API Docujmentation?

I’ve seen this (Dynamo API documentation), but how do I use this? Neither direct import nor clr.AddReference would work.


What I’m trying to do is something similar to the Ladybug’s Export Ladybug component (https://github.com/mostaphaRoudsari/ladybug/blob/master/src/Ladybug_Export%20Ladybug.py) so i could place my python scripts under VCS.