Skip to main content

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

import_transforms-0.6.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

import_transforms-0.6.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file import_transforms-0.6.0.tar.gz.

File metadata

  • Download URL: import_transforms-0.6.0.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

Hashes for import_transforms-0.6.0.tar.gz
Algorithm Hash digest
SHA256 fd923937ab9de92762f90562f69a00de1c217599e647be31677d090e31f39f8a
MD5 3b80b37450dda935476c4919967de3d2
BLAKE2b-256 5ae3cc5fc2df4296cf34707c61ab0a3be1ef1eb50c5560cbd42a0a34a2c234e9

See more details on using hashes here.

File details

Details for the file import_transforms-0.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for import_transforms-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0c34e2eb9a42f8a9816ee631aa102a0d2879079e464b4c134cd3717f3e8015e1
MD5 62ba8957dbbaab30799466b98c55b2f3
BLAKE2b-256 b2a77971dc41d87d6de0b40c652762cb3a5c9a39b4d1f313242256466f581160

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page