Hi,
I'm wondering if there are any tools available or simple methods for
taking a python source file and parsing into some hierarchical format,
like the ConfigParser. I'd like to be able to do something like the
following:
test.py:
-------------------------------------------------------
""" This is an example """
class MyClass(ParentA , ParentB):
def some_func(self, foo, bar):
self.baz = "batman"
class MyClass2(object ):
""" This is an example class """
def __init__(self):
self.a = "Blablabla"
And from the interpreter:
["MyClass", "MyClass2"]
" This is an example "
["MyClass"]
["some_func"]
""" This is an example """
class MyClass(ParentA , ParentB):
def some_func(self, foo, bar, baz):
self.baz = "batman"
Or something that would yield the above effect. Any ideas?
Thanks,
Paul
I'm wondering if there are any tools available or simple methods for
taking a python source file and parsing into some hierarchical format,
like the ConfigParser. I'd like to be able to do something like the
following:
test.py:
-------------------------------------------------------
""" This is an example """
class MyClass(ParentA , ParentB):
def some_func(self, foo, bar):
self.baz = "batman"
class MyClass2(object ):
""" This is an example class """
def __init__(self):
self.a = "Blablabla"
And from the interpreter:
>>import magicalParser
>>parsed = magicalParser.p arse(test.py)
>>parsed.getCla sses()
>>parsed = magicalParser.p arse(test.py)
>>parsed.getCla sses()
>>parsed.docStr ing
>>parsed.remove Class("MyClass2 ")
>>parsed.getCla sses()
>>parsed.getCla sses()
>>parsed.MyClas s.getFuncs()
>>parsed.MyClas s.some_func.add Param("baz")
>>parsed.printS ource()
>>parsed.printS ource()
class MyClass(ParentA , ParentB):
def some_func(self, foo, bar, baz):
self.baz = "batman"
>>exit()
Thanks,
Paul
Comment