Skip to main content

ModuleHandler

Installation

.. code:: bash

pip3 install modulehandler

Usage

Considering this folder tree

.. code:: bash

tests_import_handler
├── addons
│   └── m1
│       ├── __init__.py
│       ├── manifest.json
│       └── README.md
├── m2
│   ├── __init__.py
│   └── manifest.json
└── m3.py

.. code:: python

import ModuleHandler
from pathlib import Path
registry = ModuleHandler.ModuleRegistry()

tests_import_handler = Path("tests_import_handler").resolve()
addons = tests_import_handler.joinpath("addons")
m2 = tests_import_handler.joinpath("m2")
m3 = tests_import_handler.joinpath("m3.py")

# Register won't load
registry.register_search_dir(addons)
registry.register_module(m2)
registry.register_module(m3)

# load modules individually
m3 = registry.load("m3")  # ignore if already loader with noreload=True

# load all modules
registry.load_all()  # ignore if already loader with noreload=True

# access loaded module
m1 = registry["m1"]
m4 = registry.get("m4")  # return None

# register + load
m2 = registry.import_module(m2)

# import from search paths if not already loaded
m1 = registry.imports("m1")

# get readme as html
registry.description("m1")

# get module absolute path
registry.path("m1")

Nb:

  • This won't change sys search paths nor add modules to sys.modules: "m1" in sys.modules # False
  • loading only replace module in registry but this won't propagate to copy of old module.

Future

  • Currently, the configuration filename is not easily editable, same for configuration validation. It may be editable but still with current behaviour kept as default.

Metadata

Release files for modulehandler 0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for modulehandler 0.5
File Size Uploaded Provenance Actions
modulehandler-0.5.tar.gz 3.6 kB Without provenance Details for modulehandler-0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for modulehandler 0.5
File Interpreter ABI Platform Actions
modulehandler-0.5-py3-none-any.whl Python 3 none any Details for modulehandler-0.5-py3-none-any.whl

Total release size: 19.9 kB

Release files / modulehandler-0.5.tar.gz

Download URL modulehandler-0.5.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
07efeace5fd4643989796a8430db9631fe554a58d4e96399238c2ab44038a0e3
BLAKE2b-256 checksum
How to use checksums
1132c6ad99dce79c678e3838877c80c9faead812b934857993a8842e758c178e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

Release files / modulehandler-0.5-py3-none-any.whl

Download URL modulehandler-0.5-py3-none-any.whl
Size 16.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6be9357ca0af38464490dc21e43d02703af5e6d2e9e2b89c510b81a6be7c4ad7
BLAKE2b-256 checksum
How to use checksums
5b590d94ff8f7b7262cdbebd4bda2d9b7f8711b6f2199e0fc087e1df8e17150e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.9

Security for modulehandler 0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page