Module-related python utilities - recursive package scan, modeling of names and modules, etc
Project description
thinking-modules
Part of thinking family.
Module-related python utilities - recursive package scan and import, modeling of names and modules, etc
Main use case for this library is importing everything in given package. Simplest example are decorators that register stuff for CI, a bit like annotation scanning in Java, which need to be triggered/executed before the main portion of your program.
Besides that provides models and related utilities for modules and their names.
Requires python 3.12. Is properly typed.
API
The code is pretty self-documenting (meaning "browse the code, don't expect Sphinx"). It is organized into following modules:
thinking_modules.model
ModuleName
- represent module or package name
- doesn't import the module, is just a pointer
- allows for easy modeling of subpackages, submodules, parent packages, etc
- can refer to non-existent modules
ModuleNamePointer
- union type representing everything that can be parsed to
ModuleName
- astr
, module itself, etc
- union type representing everything that can be parsed to
Module
- is a descriptor over a python module or package
- may refer to non-existing piece of code, but will raise exception when using most methods
- allows you to recognize whether something is a module, package,
pkg.__main__
file or shell session - exposes some other useful info, like whether a module has been already imported, where is it located in filesystem
(if anywhere), what is its root package and allows you to import it with
importlib
thinking_modules.scan
- holds a single function:
scan(pkg: ModuleNamePointer)
- that function takes a package name (fails if given a non-package module name)
- it analyses filesystem, trying to find all the module names within the tree stemming from that package
- holds a single function:
thinking_modules.immutable
- helper module for something that emulates
NamedTuple
, while allowing for lazy properties - not really related to domain of this project, strictly technical, but pretty useful util
- helper module for something that emulates
Reading the test suite is gonna be useful too, in case of uncertainty.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file thinking_modules-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: thinking_modules-0.0.2-py3-none-any.whl
- Upload date:
- Size: 7.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51477311ed35770017f1b8ba2a5da7c5e9b675b2266f38a4cc4dfd673be8dea9 |
|
MD5 | a478f3b13c21dc3fc5434ed0faccb8b5 |
|
BLAKE2b-256 | 8a98be7b02f289555164883aba4647af39b4dfec06075f043e17b8dd95841290 |