# importloc
> Import Python objects from arbitrary locations
<!-- docsub: begin -->
<!-- docsub: include docs/parts/badges.md -->
[![versions](https://img.shields.io/pypi/pyversions/importloc.svg)](https://pypi.org/project/importloc)
[![pypi](https://img.shields.io/pypi/v/importloc.svg#v0.2.0)](https://pypi.python.org/pypi/importloc)
[![tested with multipython](https://img.shields.io/badge/tested_with-multipython-x)](https://github.com/makukha/multipython)
[![using docsub](https://img.shields.io/badge/using-docsub-royalblue)](https://github.com/makukha/docsub)
[![license](https://img.shields.io/github/license/makukha/importloc.svg)](https://github.com/makukha/importloc/blob/main/LICENSE)
<!-- docsub: end -->
# Features
* Import module from file `path/to/file.py`
* Import object from file `path/to/file.py:[parent.[...].]object`
* Import object from module `[pkg.[...].]module:[parent.[...].]object`
* No dependencies
* 100% test coverage *(to be implemented)*
* [Detailed documentation](http://importloc.readthedocs.io)
# Installation
<!-- docsub: begin -->
<!-- docsub: include docs/parts/installation.md -->
```shell
$ pip install importloc
```
<!-- docsub: end -->
# Usage
## [import_module_from_file](https://importloc.readthedocs.io/en/latest/#importloc.import_module_from_file)
<!-- docsub: begin -->
<!-- docsub: include tests/test_module_from_file.txt -->
<!-- docsub: lines after 1 upto -1 -->
```doctest
>>> from importloc import *
>>> foobar = import_module_from_file('example/foobar.py')
>>> foobar
<module 'foobar' from '/.../example/foobar.py'>
```
<!-- docsub: end -->
## [import_object_from_file](https://importloc.readthedocs.io/en/latest/#importloc.import_object_from_file)
<!-- docsub: begin -->
<!-- docsub: include tests/test_object_from_file.txt -->
<!-- docsub: lines after 1 upto -1 -->
```doctest
>>> from importloc import *
>>> baz = import_object_from_file('example/foobar.py:baz')
>>> baz
<function baz at 0x...>
```
<!-- docsub: end -->
## [import_object_from_module](https://importloc.readthedocs.io/en/latest/#importloc.import_object_from_module)
<!-- docsub: begin -->
<!-- docsub: include tests/test_object_from_module.txt -->
<!-- docsub: lines after 1 upto -1 -->
```doctest
>>> from importloc import *
>>> baz = import_object_from_module('example.foobar:baz')
>>> baz
<function baz at 0x...>
```
<!-- docsub: end -->
<!-- docsub: begin -->
<!-- docsub: include CHANGELOG.md -->
# Changelog
All notable changes to this project will be documented in this file. Changes for the *upcoming release* can be found in [News directory](https://github.com/makukha/importloc/tree/main/NEWS.d).
* The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
* This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
<!-- towncrier release notes start -->
## [v0.2.0](https://github.com/makukha/importloc/releases/tag/v0.2.0) — 2025-01-18
***Breaking 🔥***
- Completely rethink naming ([#20](https://github.com/makukha/importloc/issues/20))
***Fixed:***
- Wrong exception type raised when module is already imported
## [v0.1.1](https://github.com/makukha/importloc/releases/tag/v0.1.1) — 2025-01-17
***Changed:***
- When importing module from file, path is resolved to absolute ([#7](https://github.com/makukha/importloc/issues/7))
***Docs:***
- Published documentation on [importloc.readthedocs.io](https://importloc.readthedocs.io) ([#4](https://github.com/makukha/importloc/issues/4))
- Added `sphinx.ext.viewcode` plugin to view source code ([#10](https://github.com/makukha/importloc/issues/10))
- Added changelog to readme ([#12](https://github.com/makukha/importloc/issues/12))
- Added ``sphinx-sitemap`` plugin for website sitemap ([#14](https://github.com/makukha/importloc/issues/14))
- Added API version history directives ([#15](https://github.com/makukha/importloc/issues/15))
## [v0.1.0](https://github.com/makukha/importloc/releases/tag/v0.1.0) — 2025-01-15
***Added 🌿***
- Initial release ([#1](https://github.com/makukha/importloc/issues/1))
<!-- docsub: end -->
Raw data
{
"_id": null,
"home_page": null,
"name": "importloc",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "import, import-module, import-object, import-string, python",
"author": null,
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/0d/8f/088084e376946498847449c6802e7343814a10e29b9ffe10996caeeeb225/importloc-0.2.0.tar.gz",
"platform": null,
"description": "# importloc\n> Import Python objects from arbitrary locations\n\n<!-- docsub: begin -->\n<!-- docsub: include docs/parts/badges.md -->\n[![versions](https://img.shields.io/pypi/pyversions/importloc.svg)](https://pypi.org/project/importloc)\n[![pypi](https://img.shields.io/pypi/v/importloc.svg#v0.2.0)](https://pypi.python.org/pypi/importloc)\n[![tested with multipython](https://img.shields.io/badge/tested_with-multipython-x)](https://github.com/makukha/multipython)\n[![using docsub](https://img.shields.io/badge/using-docsub-royalblue)](https://github.com/makukha/docsub)\n[![license](https://img.shields.io/github/license/makukha/importloc.svg)](https://github.com/makukha/importloc/blob/main/LICENSE)\n<!-- docsub: end -->\n\n\n# Features\n\n* Import module from file `path/to/file.py`\n* Import object from file `path/to/file.py:[parent.[...].]object`\n* Import object from module `[pkg.[...].]module:[parent.[...].]object`\n* No dependencies\n* 100% test coverage *(to be implemented)*\n* [Detailed documentation](http://importloc.readthedocs.io)\n\n\n# Installation\n<!-- docsub: begin -->\n<!-- docsub: include docs/parts/installation.md -->\n```shell\n$ pip install importloc\n```\n<!-- docsub: end -->\n\n\n# Usage\n\n## [import_module_from_file](https://importloc.readthedocs.io/en/latest/#importloc.import_module_from_file)\n\n<!-- docsub: begin -->\n<!-- docsub: include tests/test_module_from_file.txt -->\n<!-- docsub: lines after 1 upto -1 -->\n```doctest\n>>> from importloc import *\n>>> foobar = import_module_from_file('example/foobar.py')\n>>> foobar\n<module 'foobar' from '/.../example/foobar.py'>\n```\n<!-- docsub: end -->\n\n## [import_object_from_file](https://importloc.readthedocs.io/en/latest/#importloc.import_object_from_file)\n\n<!-- docsub: begin -->\n<!-- docsub: include tests/test_object_from_file.txt -->\n<!-- docsub: lines after 1 upto -1 -->\n```doctest\n>>> from importloc import *\n>>> baz = import_object_from_file('example/foobar.py:baz')\n>>> baz\n<function baz at 0x...>\n```\n<!-- docsub: end -->\n\n## [import_object_from_module](https://importloc.readthedocs.io/en/latest/#importloc.import_object_from_module)\n\n<!-- docsub: begin -->\n<!-- docsub: include tests/test_object_from_module.txt -->\n<!-- docsub: lines after 1 upto -1 -->\n```doctest\n>>> from importloc import *\n>>> baz = import_object_from_module('example.foobar:baz')\n>>> baz\n<function baz at 0x...>\n```\n<!-- docsub: end -->\n\n\n<!-- docsub: begin -->\n<!-- docsub: include CHANGELOG.md -->\n# Changelog\n\nAll notable changes to this project will be documented in this file. Changes for the *upcoming release* can be found in [News directory](https://github.com/makukha/importloc/tree/main/NEWS.d).\n\n* The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)\n* This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html)\n\n<!-- towncrier release notes start -->\n\n## [v0.2.0](https://github.com/makukha/importloc/releases/tag/v0.2.0) \u2014 2025-01-18\n\n***Breaking \ud83d\udd25***\n\n- Completely rethink naming ([#20](https://github.com/makukha/importloc/issues/20))\n\n***Fixed:***\n\n- Wrong exception type raised when module is already imported\n\n\n## [v0.1.1](https://github.com/makukha/importloc/releases/tag/v0.1.1) \u2014 2025-01-17\n\n***Changed:***\n\n- When importing module from file, path is resolved to absolute ([#7](https://github.com/makukha/importloc/issues/7))\n\n***Docs:***\n\n- Published documentation on [importloc.readthedocs.io](https://importloc.readthedocs.io) ([#4](https://github.com/makukha/importloc/issues/4))\n- Added `sphinx.ext.viewcode` plugin to view source code ([#10](https://github.com/makukha/importloc/issues/10))\n- Added changelog to readme ([#12](https://github.com/makukha/importloc/issues/12))\n- Added ``sphinx-sitemap`` plugin for website sitemap ([#14](https://github.com/makukha/importloc/issues/14))\n- Added API version history directives ([#15](https://github.com/makukha/importloc/issues/15))\n\n\n## [v0.1.0](https://github.com/makukha/importloc/releases/tag/v0.1.0) \u2014 2025-01-15\n\n***Added \ud83c\udf3f***\n\n- Initial release ([#1](https://github.com/makukha/importloc/issues/1))\n<!-- docsub: end -->\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Import Python objects from arbitrary locations",
"version": "0.2.0",
"project_urls": {
"Changelog": "https://github.com/makukha/importloc/releases",
"Documentation": "https://importloc.readthedocs.io",
"Homepage": "https://github.com/makukha/importloc",
"Issues": "https://github.com/makukha/importloc/issues",
"Repository": "https://github.com/makukha/importloc"
},
"split_keywords": [
"import",
" import-module",
" import-object",
" import-string",
" python"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "35e0c912c379446d1279ca2f0dfa1f5d60ee84653c9d10087ea0158efffad184",
"md5": "e26731a8cc58cdef73d202204f64cbc5",
"sha256": "2943bea0990d21a78bcc571b6bdd8f1207bde2dc6df622f125273998f3f303b1"
},
"downloads": -1,
"filename": "importloc-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e26731a8cc58cdef73d202204f64cbc5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 5213,
"upload_time": "2025-01-18T13:29:21",
"upload_time_iso_8601": "2025-01-18T13:29:21.953474Z",
"url": "https://files.pythonhosted.org/packages/35/e0/c912c379446d1279ca2f0dfa1f5d60ee84653c9d10087ea0158efffad184/importloc-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0d8f088084e376946498847449c6802e7343814a10e29b9ffe10996caeeeb225",
"md5": "0ce63a3905512568fd0b019d28c3905d",
"sha256": "82fc70a14adbd14483df5c3b8d8b8f0f0448fc13ba71a35047bf099362aadb4b"
},
"downloads": -1,
"filename": "importloc-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "0ce63a3905512568fd0b019d28c3905d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 74460,
"upload_time": "2025-01-18T13:29:24",
"upload_time_iso_8601": "2025-01-18T13:29:24.772044Z",
"url": "https://files.pythonhosted.org/packages/0d/8f/088084e376946498847449c6802e7343814a10e29b9ffe10996caeeeb225/importloc-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-18 13:29:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "makukha",
"github_project": "importloc",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"tox": true,
"lcname": "importloc"
}