trying to find a python library or to find the best way to find methods from python code files
for example, app.py
from django.conf.urls import url
from oscar.core.loading import get_class
class SearchApplication(Application):
name = 'search'
search_view = get_class('search.views', 'FacetedSearchView')
search_form = get_class('search.forms', 'SearchForm')
def get_urls(self):
# The form class has to be passed to the __init__ method as that is how
# Haystack works. It's slightly different to normal CBVs.
urlpatterns = [
url(r'^$', search_view_factory(
view_class=self.search_view,
form_class=self.search_form,
searchqueryset=self.get_sqs()),
name='search'),
]
return self.post_process_urls(urlpatterns)
and my aim is to write code that takes that file app.py as input as text or as file(either way is fine) and outputs something like this:
{
"methods": [
{"name": "get_urls", "class": "SearchApplication", "line": 9, "args": [self], "kwargs": []}
],
"classs": [
{"name": "SearchApplication", "inherits_from": "Application", "line": 5}
]
}
thanks. please ask if the intention is unclear or if the question is missing data.
ast.parse.