get extra info about python modules
Project description
Py Module Info
Get extra info about a python module, like imports, functions called inside other funcs etc.
What does it do?
Get info about the imports used
# test.py
import json
import pprint as p
from typing import List as l
from json import load, dump as d
from py_module_info.main import ModuleInfo
To get the imported names use
from py_module_info import ModuleInfo
m = ModuleInfo("test.py")
imports = m.get_imports()
print(imports.get_imported_names())
# output
['json', 'pprint', 'List', 'load', 'dump', 'ModuleInfo']
# in order to get the alias names used
print(imports.get_imported_names(use_alias=True))
# output
['json', 'p', 'l', 'load', 'd', 'ModuleInfo']
To get the literal import string in the module use
from py_module_info import ModuleInfo
m = ModuleInfo("test.py")
imports = m.get_imports()
print(imports.get_import_strings())
# output
['import json', 'import pprint', 'from typing import List',
'from json import load', 'from json import dump', 'from py_module_info.main import ModuleInfo']
# use alias names insted
print(imports.get_import_strings(use_alias=True))
# output
['import json', 'import pprint as p', 'from typing import List as l',
'from json import load', 'from json import dump as d', 'from py_module_info.main import ModuleInfo']
Note
- The imports will be split into individual imports:
import test, json
- will become
import test
import json
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
py-module-info-0.0.0.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for py_module_info-0.0.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8e12af745bfbcf08213b0f80eef054f2b25cd63e06cbd5697456bebd03bf3d8 |
|
MD5 | 2b244b1013fb4e24d697277f28208eb9 |
|
BLAKE2b-256 | b6d8cd8107ea8eb1a2a1c43f886055dd489034b81b15d4beb005bc8321cc4ffe |