Skip to main content

Documentation | Get Started | Developer Chat

DeepSource helps you ship good quality code.


import-x

An ext-tensible loader to import anything like it is a python module.

Supports Python 3.6+.

Installation

pip install import-x

Usage

Example json file in your path foo.json:

    {
        "why": "not",
    }
   # Extend the ExtensionLoader and implement 'handle_module' method
   # where you will get a module object and the path to that module.

   >>> from import_x import ExtensionLoader

   >>> class JsonLoader(ExtensionLoader):
        extension = '.json'

        auto_enable = False

        @staticmethod
        def handle_module(module, path):
            """
            Load the json file and set as `data` attribute of the module.
            """
            json_file = Path(path)
            content = json_file.read_text()
            try:
                data = json.loads(content)
            except (json.JSONDecodeError, ValueError):
                data = {}
            module.data = data

    >>> json_imports = JsonLoader()
    >>> with json_imports:
            import foo
    >>> foo.data
    >>> {"why": "not"}

If you want to enable imports automatically without the context_manager then just do auto_enable = True in your loader.

This Example JsonLoader can be used directly by importing

    from import_x.loaders.json_loader import JsonLoader

and you are ready to import all the json files.

Metadata

Release files for import-x 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for import-x 0.1.1
File Size Uploaded Provenance Actions
import-x-0.1.1.tar.gz 3.9 kB Without provenance Details for import-x-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for import-x 0.1.1
File Interpreter ABI Platform Actions
import_x-0.1.1-py3-none-any.whl Python 3 none any Details for import_x-0.1.1-py3-none-any.whl

Total release size: 8.2 kB

Release files / import-x-0.1.1.tar.gz

Download URL import-x-0.1.1.tar.gz
Size 3.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9b9b603b280f553eb075a01f877b9f1afa1de045b41d10508b667c2311324e2d
BLAKE2b-256 checksum
How to use checksums
aab38322b911337b4ad4a8c31a6679afcb9050b1086e1bbab4163525fec51c5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.4 Linux/5.2.14-arch1-1-ARCH

Release files / import_x-0.1.1-py3-none-any.whl

Download URL import_x-0.1.1-py3-none-any.whl
Size 4.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cfd7c9503b0aeb95d23fb80193964b7874fd5c2bf24f136a4a92f4c03b391990
BLAKE2b-256 checksum
How to use checksums
06264535a64bb032bab4866e1d08be609152736e05691c2f852d0ca5d17944e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/0.12.17 CPython/3.7.4 Linux/5.2.14-arch1-1-ARCH

Security for import-x 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page