Skip to main content

Python module wrapper for dynamic loading and callable signature validation.

Project description

modwrap is a pure Python 3 utility (no external dependencies) that lets you dynamically load and execute functions from any Python module — either via code or command line. 🐍

📦 Installation

Install directly from PyPI:

pip install modwrap

🔧 Programmatic Usage

Use modwrap in your Python code to load modules, introspect callable signatures, and execute functions dynamically:

from modwrap import ModuleWrapper

wrapper = ModuleWrapper("./examples/shell.py")

# Optional: Validate the function signature before calling
wrapper.validate_signature("execute", {"command": str})

# Load and call the function
func = wrapper.get_callable("execute")
result = func(command="whoami")
print(result)

You can also access the raw module object:

mod = wrapper.module
print(mod.execute("whoami"))

💻 CLI Usage

modwrap comes with a command-line interface to easily inspect and interact with any Python module.

List available callables and their signatures

modwrap list ./examples/shell.py

Returns a JSON-formatted list of top-level functions with argument type hints.

Get docstrings

modwrap doc ./examples/shell.py --full

Call a function with positional arguments

modwrap call ./examples/shell.py execute "ls -tAbl"

Call a function with keyword arguments

modwrap call ./examples/shell.py execute --kwargs '{"command": "ls -tAbl"}'

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

modwrap-1.0.6.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

modwrap-1.0.6-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file modwrap-1.0.6.tar.gz.

File metadata

  • Download URL: modwrap-1.0.6.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Linux/6.12.20-amd64

File hashes

Hashes for modwrap-1.0.6.tar.gz
Algorithm Hash digest
SHA256 7f02ac1db66aea85c13d7f639cf1dc70c1831c604a8d8a82f52a8483c596a177
MD5 47c6270be438601cb7d0b2be0e4117bd
BLAKE2b-256 4c460bac3ba6e9e397a3abc48ea56e1b2f42a5e2b6b66ea821b6052f27720f72

See more details on using hashes here.

File details

Details for the file modwrap-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: modwrap-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Linux/6.12.20-amd64

File hashes

Hashes for modwrap-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d42ddb4b9b0532a37648c2c07cd9a1f8a17cd8a707768291b400922900fea306
MD5 dd313f970c6b1a9adecc165f96c1c658
BLAKE2b-256 e553016de3939e007cfc9186256b09189ac005e483e2010f13b4c45f2b5fd483

See more details on using hashes here.

Supported by

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