No project description provided
Project description
import-transforms is a Python library for intercepting and transforming source code at import time. Its main use is unit-syntax, which modifies the Python syntax to support units of measure.
Usage
Transforms are defined by extending import_transforms.SourceTransform. For a small example that adds logging of every single function call, see call_log.py.
To apply a transform to future module imports:
register_module_source_transform("target_module", my_transform)
import target_module # transform applied!
The first argument is a glob-style pattern on the fully-qualified module name:
- "foo" matches just that single module.
- "foo.*" matches all sub-modules of "foo" (but not "foo" itself).
- "*" will match all modules.
As a shorthand to apply a transform to all sub-modules of your package, place this in __init__.py:
register_package_source_transform(__name__, my_transform)
TODO
- check/support bytecode cached files
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file import_transforms-0.6.1.tar.gz.
File metadata
- Download URL: import_transforms-0.6.1.tar.gz
- Upload date:
- Size: 3.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d6a471d9d620e5cfe779a5819c128c2ca3154cd7dd167ef76305f2834e80b2f
|
|
| MD5 |
b0702e73135a76fe08e175cd212ab008
|
|
| BLAKE2b-256 |
e27761fa76694f01f6ce49fb862f20f4767a479724bf41d1e63e6ed476ae014b
|
File details
Details for the file import_transforms-0.6.1-py3-none-any.whl.
File metadata
- Download URL: import_transforms-0.6.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7ca2447a5c9dc83705abb96545877178ae9a027aeac3cbe0b1d259342a64688
|
|
| MD5 |
b825c30b4c1e532ec8a249786e647f86
|
|
| BLAKE2b-256 |
b308571cb5bfed1ff3c06fe985754571e737e5ad093605676b0f08cc99dd3071
|