midir
A library for resolving relative module dependencies.
Description
midir is a Python library designed to handle relative module dependencies by resolving directory paths in an intelligent and system-agnostic way. This library can be used to introspect the file structure of your project and manipulate Python's sys.path, allowing for dynamic module imports based on directory hierarchy. It is especially helpful for larger projects where file structure can become complex and static imports cumbersome to manage.
Features
-
get_caller() -> str:Returns the name of the file or the location (directory) where the current execution point is present. -
mipath(path: str = None) -> str | Path:Returns the canonical (absolute) path of the current execution point or a provided path. -
midir(path: str = None) -> str | Path:Returns the directory name where the current execution point is or from a provided path. -
root_levels(levels: int = 1) -> None:Makes directories available for import by adding them to sys.path. It starts from directory of the caller file and move up the directory hierarchy. The number of levels up to move is determined by input argument. -
root_suffix(suffix: str) -> None:Similar toroot_levels, but instead of moving up a certain number of directories, it continues to move up until it finds a directory whose name ends with the provided suffix and adds that directory to sys.path. -
lsdir(path: str) -> List[str]:This function retrieves a sorted list of file and/or folder names from a specified directory path. Whether it returns file or folder names depends on the parameters set. It returns the full path of these files/folders if requested. Custom filter conditions can be applied. Raises errors if path isn't found or if no output requirements are specified. A warning is given if both file and folder parameters are set to true while a custom filter function is also specified.
Exceptions
FolderNotFoundError:Custom exception raised when no folder matching the required conditions (inroot_suffix) is found in the directory hierarchy.
Testing
cd midir
source bin/activate
pytest .
cd midir
source bin/activate
python -m tests.test_unit
Build instructions
- Building the package before uploading: 'python -m build' (from "midir").
- Upload the package to pypi: 'python -m twine upload --repository pypi dist/*'
- Install the package from pypi: 'python -m pip install midir'
- If any dependencies are required, edit the
pyproject.tomlfile, "[project]" field, and add adependencieskey with aList\[str\]value, where each string is apip-readable dependency.
Metadata
Release files for midir 1.2.2
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 |
|---|---|---|---|---|
| midir-1.2.2.tar.gz | 6.4 kB | Without provenance | Details for midir-1.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| midir-1.2.2-py3-none-any.whl | Python 3 | none | any | Details for midir-1.2.2-py3-none-any.whl |
Total release size: 12.6 kB
Release files / midir-1.2.2.tar.gz
| Download URL | midir-1.2.2.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e49fe792bf79ce73b5f13b79516c732278f415266220c63da8a5f8d044e3ad53
|
|
BLAKE2b-256 checksum How to use checksums |
32b2130c3f2a49ed4fba4f599fcc6d7459c7e13cce261bd12dd3189ea61ef373
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.7
|
Release files / midir-1.2.2-py3-none-any.whl
| Download URL | midir-1.2.2-py3-none-any.whl |
|---|---|
| Size | 6.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1de1763bc4000b5485f34c129f9a55959618228e1161a017ae683cf0f7652bfa
|
|
BLAKE2b-256 checksum How to use checksums |
dec0c6f8f9e7e924f7dd5130fa1bb097fca1dc3560e3dbad52650ce827695b44
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.7
|
Security for midir 1.2.2
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.