You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
"""
Python utilities for the ein inspector.
Copyright (C) 2017- John M. Miller
Author: John Miller <millejoh at gmail.com>
ein_inspector.py is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.
ein_inspector.py is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.
You should have received a copy of the GNU General Public Licensealong with ein_inspector.py. If not, see <http://www.gnu.org/licenses/>.
"""
import jsonimport inspect
def generate_inspector_data(obj_str, globals, locals): odata = {'name': obj_str} try: obj = eval(obj_str, globals, locals) except NameError: odata['error'] = 'Object {} not found.'.format(obj_str) else: odata['doc'] = inspect.getdoc(obj) odata['type'] = str(type(obj)) odata['repr'] = str(obj) try: odata['source_file'] = inspect.getsourcefile(obj) odata['source_lines'] = inspect.getsourcelines(obj) except: odata['source_file'] = None odata['source_lines'] = None print(json.dumps(odata)) return odata
|