Name | pyclsload JSON |
Version |
1.5.0
JSON |
| download |
home_page | None |
Summary | None |
upload_time | 2024-09-02 20:11:14 |
maintainer | nbdy |
docs_url | None |
author | nbdy |
requires_python | >=3.8 |
license | MIT License |
keywords |
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# pyclsload
[](https://www.codefactor.io/repository/github/nbdy/pyclsload)
easily load classes from source files
it's basically just a wrapper around importlib
## why?
```python
# doesn't look
from pyclsload import load_cls
this_a_class = load_cls("somefile.py", "ThisAClass")
this_a_class.somemethod()
# better than
from importlib.util import spec_from_file_location, module_from_spec
s = spec_from_file_location("ThisAClass", "somefile.py")
m = module_from_spec(s)
s.loader.exec_module(m)
this_a_class = m.__dict__["ThisAClass"]()
this_a_class.somemethod()
```
## features
- [X] Load class from file (load_cls)
- [X] Load classes from directory (load_dir)
see the [tests](/tests) to get a better understanding on how to use it
## install
```shell
pip install pyclsload
```
Raw data
{
"_id": null,
"home_page": null,
"name": "pyclsload",
"maintainer": "nbdy",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": null,
"author": "nbdy",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/24/a6/c06f62ba2cd786aa78f111ae98338628016f62fdef1101c634e75014584e/pyclsload-1.5.0.tar.gz",
"platform": null,
"description": "# pyclsload\n\n[](https://www.codefactor.io/repository/github/nbdy/pyclsload)\n\neasily load classes from source files\n\nit's basically just a wrapper around importlib\n\n## why?\n\n```python\n# doesn't look\nfrom pyclsload import load_cls\nthis_a_class = load_cls(\"somefile.py\", \"ThisAClass\")\nthis_a_class.somemethod()\n\n# better than\nfrom importlib.util import spec_from_file_location, module_from_spec\ns = spec_from_file_location(\"ThisAClass\", \"somefile.py\")\nm = module_from_spec(s)\ns.loader.exec_module(m)\nthis_a_class = m.__dict__[\"ThisAClass\"]()\nthis_a_class.somemethod()\n```\n\n## features\n\n- [X] Load class from file (load_cls)\n- [X] Load classes from directory (load_dir)\n\nsee the [tests](/tests) to get a better understanding on how to use it\n\n## install\n\n```shell\npip install pyclsload\n```\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": null,
"version": "1.5.0",
"project_urls": {
"Homepage": "https://github.com/nbdy/pyclsload",
"Issues": "https://github.com/nbdy/pyclsload/issues",
"Repository": "https://github.com/nbdy/pyclsload.git"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "24a6c06f62ba2cd786aa78f111ae98338628016f62fdef1101c634e75014584e",
"md5": "5f670a6a3faecffdbc8d5b8cd9a2e1ad",
"sha256": "e4dcfdf42e9e5d9e4c642f3e8813058fbb12340adce4bdfba082937fb6186352"
},
"downloads": -1,
"filename": "pyclsload-1.5.0.tar.gz",
"has_sig": false,
"md5_digest": "5f670a6a3faecffdbc8d5b8cd9a2e1ad",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6157,
"upload_time": "2024-09-02T20:11:14",
"upload_time_iso_8601": "2024-09-02T20:11:14.410178Z",
"url": "https://files.pythonhosted.org/packages/24/a6/c06f62ba2cd786aa78f111ae98338628016f62fdef1101c634e75014584e/pyclsload-1.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-02 20:11:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nbdy",
"github_project": "pyclsload",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "pyclsload"
}