modulehooks
modulehooks is a Python module used to wrap another
module with various hooks that trigger when a variable
is assigned to (for example, sys.excepthook). Currently
there is only one type of hook, FunctionHook, which
adds the function to a callback list that all gets called
when the hook is called.
This is particularly useful
with attributes such as sys.excepthook that could
be overwritten by any other script, and with a
FunctionHook all functions that were assigned to it
will be stored and called when needed.
Example
import sys
from modulehooks import ModuleWrapper, FunctionHook
class SysWrapper(ModuleWrapper):
excepthook = FunctionHook(sys.excepthook)
_names = ["excepthook"]
_restricted = ["__excepthook__"]
wrapper = SysWrapper.create(sys)
sys.modules["sys"] = wrapper
sys = wrapper
_names is used to declare all hooks that are defined,
_restricted is used to declare attributes that cannot
be modified or deleted and create creates a wrapper
around the specified module. Remember to modify
sys.modules as well otherwise import will load the
default Python module and not your custom wrapper.
Metadata
Release files for modulehooks 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| modulehooks-1.0.0.tar.gz | 3.1 kB | Without provenance | Details for modulehooks-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| modulehooks-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for modulehooks-1.0.0-py3-none-any.whl |
Total release size: 6.5 kB
Release files / modulehooks-1.0.0.tar.gz
| Download URL | modulehooks-1.0.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34b063d68f3e55bce45cead92fa9f4ae36313084785409a4efa27e427af21bf8
|
|
BLAKE2b-256 checksum How to use checksums |
d6e183c7eaf2fc0ee0940f51d12e16be9a9faa75bce19a4280ea8a45c62f710b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.4
|
Release files / modulehooks-1.0.0-py3-none-any.whl
| Download URL | modulehooks-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
58cd6c7edf7b8c2a2cb99289f2cb45cb830e584810b54af64533215f184a0119
|
|
BLAKE2b-256 checksum How to use checksums |
11d519722722e95ce6848aa483802a168045c26750ea085c58e1765b0adc9084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.4
|
Security for modulehooks 1.0.0
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.