I have a python file that is a collection functions, classes with methods etc. I need to parse it so that I can just extract out the specified functions and classes including the methods that I need for the purpose of over-riding them.
Is there a parser that can parse python code well for this kind of requirement? Will the inbuilt ast module help me?
For example:
Input: Main.py
def f_one():
"""
"""
pass
class c_one():
"""
"""
def m_one():
"""
"""
pass
def m_two():
"""
"""
pass
def m_three():
"""
"""
pass
class c_two():
def m_one():
"""
"""
pass
Goal is to just copy across f_one, c_one and m_one, more generally the code (function, class etc) that I specify.
Output: Copy.py
def f_one():
"""
"""
pass
class c_one():
"""
"""
def m_one():
"""
"""
pass