Rule for generating python code in GRC

Any people know the implementation of the generating python code in GRC?
What is the rule for generating python code from GRC file?
Any body can provide the detail document for me in explaining the
implementation detail in this code generation function?
Thanks a lot!