Skip to main content

No project description provided

Project description

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

  1. midir(path: str) -> str: Returns the directory name of the given file or directory path.

  2. get_caller() -> str: Returns the name of the file or the location (directory) where the current execution point is present.

  3. mipath(path: str = None) -> str: Returns the canonical (absolute) path of the current execution point or a provided path.

  4. midir(path: str = None) -> str: Returns the directory name where the current execution point is or from a provided path.

  5. 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.

  6. root_suffix(suffix: str) -> None: Similar to root_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.

Exceptions

  1. FolderNotFoundError: Custom exception raised when no folder matching the required conditions (in root_suffix) is found in the directory hierarchy.

Build instructions

  1. Building the package before uploading: 'python -m build' (from "midir").
  2. Upload the package to pypi: 'python -m twine upload --repository pypi dist/*'
  3. Install the package from pypi: 'python -m pip install midir'
  4. If any dependencies are required, edit the pyproject.toml file, "[project]" field, and add a dependencies key with a List\[str\] value, where each string is a pip-readable dependency.

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

midir-1.1.0.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

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

midir-1.1.0-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file midir-1.1.0.tar.gz.

File metadata

  • Download URL: midir-1.1.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for midir-1.1.0.tar.gz
Algorithm Hash digest
SHA256 71c2657b04940a1717ef8cd667f7fa2ab18c740dcb33385f319f2334e6e7cb30
MD5 50e4df848689d131e4a92c836a6e1066
BLAKE2b-256 74997b8f5f4bf50112afeaeca54b94c3afdd735647da9a5f17c0262b3ae9dc88

See more details on using hashes here.

File details

Details for the file midir-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: midir-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for midir-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ef909a52566ccdc0a97ca6f8b301ad9a51e05b960326b41a7ed8fb88eb00e5e
MD5 fdcd544d9eb453ac2beb811a06d5a63a
BLAKE2b-256 e41da6a85b13faa8f43cb67f97fa55fd33b8d1826fb5e14a5b75a32feadff040

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