W
Wilson
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:
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:
""" This is an example """import magicalParser
parsed = magicalParser.parse(test.py)
parsed.getClasses() ["MyClass", "MyClass2"]
parsed.docString " This is an example "
parsed.removeClass("MyClass2")
parsed.getClasses() ["MyClass"]
parsed.MyClass.getFuncs() ["some_func"]
parsed.MyClass.some_func.addParam("baz")
parsed.printSource()
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