import-autoload


Nameimport-autoload JSON
Version 0.3.1 PyPI version JSON
download
home_page
SummaryThis helper provides simplified loading of modules (files) from package (dir)
upload_time2023-04-03 16:43:52
maintainer
docs_urlNone
authorJL Connor
requires_python>=3
licenseGLWTPL
keywords autoload autoloader import module
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # import autoload
![Lines of code](https://img.shields.io/tokei/lines/github/ablaternae/py-autoload)
![Downloads](https://img.shields.io/pypi/dm/import-autoload)
[![Statistic](https://pepy.tech/badge/import-autoload/week)](https://pepy.tech/project/import-autoload)
[![GitHub](https://img.shields.io/github/license/ablaternae/py-tripcode)](https://github.com/ablaternae/py-autoload/blob/trunk/LICENSE.md)

## What is autoloading?

Autoloading means the automatic loading of the files required for your module. That is including the files required for your application without explicitly including each file with `from modulename import filename` construct.

### 1. problem 

* let directory struct be like
```
main.py
project_dir/
|-- example.py
|-- README.md
|-- setup.py
|-- test_package
|   |-- __init__.py
|   |-- package_file_0.py
|   |-- package_file_1.py
|   |-- package_file_2.py
```

* and code
```python
"""example.py"""
from test_package import package_file_0
from test_package import package_file_1
...
from test_package import package_file_n
```
but we are too lazy to type a lot letters

### 2. solution
* install
```bash
pip install -UIv "import-autoload>=0.2.4a"
```
* add two lines to `__init__.py` 
```python
"""__init__.py"""
from autoload import autoload

__all__ = autoload()
```
```python
"""example.py"""
from test_package import *
```
* or variant
```python
"""main.py"""
from autoload import autoload

autoload("project_dir.test_package", pattern="package_file_[0123]")
```

### parameters
1. `module_name` path to module dir with **dot** separator, like in `from module_name import`, default current module
2. `pattern` like in `fnmatch(filename, pattern)`, default `*.py`

### attention
* it seems to require python version >= 3.4. if you were able to test an early version, please contact me

### how it work
* checks path to module and call `importlib.import_module()`
## License
* It's opensource and free software, see the [LICENSE](LICENSE) for more details

## similar projects
* [import-export](https://pypi.org/project/import-export/)
* another [autoloader](https://pypi.org/project/autoload-module/)

## TODO
* [ ] handle system path separator for module_name

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "import-autoload",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3",
    "maintainer_email": "",
    "keywords": "autoload,autoloader,import,module",
    "author": "JL Connor",
    "author_email": "",
    "download_url": "",
    "platform": null,
    "description": "# import autoload\r\n![Lines of code](https://img.shields.io/tokei/lines/github/ablaternae/py-autoload)\r\n![Downloads](https://img.shields.io/pypi/dm/import-autoload)\r\n[![Statistic](https://pepy.tech/badge/import-autoload/week)](https://pepy.tech/project/import-autoload)\r\n[![GitHub](https://img.shields.io/github/license/ablaternae/py-tripcode)](https://github.com/ablaternae/py-autoload/blob/trunk/LICENSE.md)\r\n\r\n## What is autoloading?\r\n\r\nAutoloading means the automatic loading of the files required for your module. That is including the files required for your application without explicitly including each file with `from modulename import filename` construct.\r\n\r\n### 1. problem \r\n\r\n* let directory struct be like\r\n```\r\nmain.py\r\nproject_dir/\r\n|-- example.py\r\n|-- README.md\r\n|-- setup.py\r\n|-- test_package\r\n|   |-- __init__.py\r\n|   |-- package_file_0.py\r\n|   |-- package_file_1.py\r\n|   |-- package_file_2.py\r\n```\r\n\r\n* and code\r\n```python\r\n\"\"\"example.py\"\"\"\r\nfrom test_package import package_file_0\r\nfrom test_package import package_file_1\r\n...\r\nfrom test_package import package_file_n\r\n```\r\nbut we are too lazy to type a lot letters\r\n\r\n### 2. solution\r\n* install\r\n```bash\r\npip install -UIv \"import-autoload>=0.2.4a\"\r\n```\r\n* add two lines to `__init__.py` \r\n```python\r\n\"\"\"__init__.py\"\"\"\r\nfrom autoload import autoload\r\n\r\n__all__ = autoload()\r\n```\r\n```python\r\n\"\"\"example.py\"\"\"\r\nfrom test_package import *\r\n```\r\n* or variant\r\n```python\r\n\"\"\"main.py\"\"\"\r\nfrom autoload import autoload\r\n\r\nautoload(\"project_dir.test_package\", pattern=\"package_file_[0123]\")\r\n```\r\n\r\n### parameters\r\n1. `module_name` path to module dir with **dot** separator, like in `from module_name import`, default current module\r\n2. `pattern` like in `fnmatch(filename, pattern)`, default `*.py`\r\n\r\n### attention\r\n* it seems to require python version >= 3.4. if you were able to test an early version, please contact me\r\n\r\n### how it work\r\n* checks path to module and call `importlib.import_module()`\r\n## License\r\n* It's opensource and free software, see the [LICENSE](LICENSE) for more details\r\n\r\n## similar projects\r\n* [import-export](https://pypi.org/project/import-export/)\r\n* another [autoloader](https://pypi.org/project/autoload-module/)\r\n\r\n## TODO\r\n* [ ] handle system path separator for module_name\r\n",
    "bugtrack_url": null,
    "license": "GLWTPL",
    "summary": "This helper provides simplified loading of modules (files) from package (dir)",
    "version": "0.3.1",
    "split_keywords": [
        "autoload",
        "autoloader",
        "import",
        "module"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2701f411ceee8a0f30601faa11b2228784171f813077e10173ffb7fc34cb0c6d",
                "md5": "83a0cfcc57a658d7cf88c51e2069e14f",
                "sha256": "34bcf7964612430c4b2403ea2b4f4ed5033cac3d19edf64c021d6c3adc60ab83"
            },
            "downloads": -1,
            "filename": "import_autoload-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "83a0cfcc57a658d7cf88c51e2069e14f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3",
            "size": 5593,
            "upload_time": "2023-04-03T16:43:52",
            "upload_time_iso_8601": "2023-04-03T16:43:52.502449Z",
            "url": "https://files.pythonhosted.org/packages/27/01/f411ceee8a0f30601faa11b2228784171f813077e10173ffb7fc34cb0c6d/import_autoload-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-03 16:43:52",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "import-autoload"
}
        
Elapsed time: 0.05936s