Module Tools
Project description
Module Tools
Tools for python modules
Installation
$ pip install module-tools
Examples
"""
package
__init__.py
sub_package
__init__.py
modulec.py -> var5, var6 = 3, "c"
modulea.py -> var1, var2, add = 1, "a", lambda a, b: a + b
moduleb.py -> var3, var4 = 2, "b"
"""
from package.modulea import add
from module_tools import find_module_strings, find_modules, import_string, iter_objs_from_modules
add1 = import_string("package.modulea.add")
print(add1 is add) # True
print(set(find_module_strings("package")) == {"package.modulea", "package.moduleb"}) # True
print(
set(find_module_strings("package", recursive=True))
== {"package.modulea", "package.moduleb", "package.sub_pakage.modulec"}
) # True
from package import modulea, moduleb
from package.sub_package import modulec
print(set(find_modules("package")) == {modulea, moduleb}) # True
print(set(find_modules("package", recursive=True)) == {modulea, moduleb, modulec}) # True
print(set(iter_objs_from_modules(["package"], cls=int)) == {1, 2}) # True
print(set(iter_objs_from_modules(["package"], cls=int, recursive=True)) == {1, 2, 3}) # True
print(
set(iter_objs_from_modules(["package"], cls=int, recursive=True, func=lambda x: x < 3))
== {1, 2}
) # True
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
module-tools-0.0.3.tar.gz
(3.7 kB
view details)
Built Distribution
File details
Details for the file module-tools-0.0.3.tar.gz
.
File metadata
- Download URL: module-tools-0.0.3.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7a39de5d5ccd8fadf6408364b8c39128ba0f888e27a834b9ee0c504295827a7 |
|
MD5 | 533d1e71f42bf5fc8c5c6b8afda0a5be |
|
BLAKE2b-256 | 2fad6e9652839fb00bb81bceb0d9ccb2a7ca006d4713c2e0677621f5129cf6a4 |
File details
Details for the file module_tools-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: module_tools-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 308fca3fe0058dffa7681377c33cd5a648397cae9287295eda267ef7c2f29e28 |
|
MD5 | 343e8f8bfc736cb6edf654f2adcf110a |
|
BLAKE2b-256 | 3adb04e52f27cb3c9aa77d3083963e823acaf908c767644c6a5d00ad69bd0a50 |