Skip to main content

A dynamic module handler, with standalone tools

Project description

ModuleHandler

Installation

pip3 install modulehandler

Usage

Considering this folder tree

tests_import_handler
├── addons
│   └── m1
│       ├── __init__.py
│       ├── manifest.json
│       └── README.md
├── m2
│   ├── __init__.py
│   └── manifest.json
└── m3.py
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.

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

modulehandler-0.2.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

modulehandler-0.2-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file modulehandler-0.2.tar.gz.

File metadata

  • Download URL: modulehandler-0.2.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using 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.2 CPython/3.6.9

File hashes

Hashes for modulehandler-0.2.tar.gz
Algorithm Hash digest
SHA256 972ad7476af97b3bdfb352952dedf500bb807c488187d2d8a2363f75f628ba93
MD5 25d56c6350642affd81e60e708228e03
BLAKE2b-256 e78215a5da0d98125f54dd59fd127ed3ee52ef0dc97952d657e204d3eddd86ae

See more details on using hashes here.

File details

Details for the file modulehandler-0.2-py3-none-any.whl.

File metadata

  • Download URL: modulehandler-0.2-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using 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.2 CPython/3.6.9

File hashes

Hashes for modulehandler-0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7b5c55f007d0a0937c7d41bde112cea543e6901ab51dc892662cfd4173827023
MD5 1d0d82e0f44a17e3a298b38027b2e33d
BLAKE2b-256 da205c84c83c58ef1653781968f6d0bd0f7119539a67c4574ee093eab7ff8651

See more details on using hashes here.

Supported by

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