dynamic module importer
Project description
dynaport
Dynaport serves as a python module that will enable you to dynamically import modules from anywhere on the filesystem. This module acts as a wrapper of the python import library to offer an easy to use syntax for dynamically importing modules in python. Dynaport is able to support Python2, Python3.3, Python3.4, and Python3.5+ automatically.
installation
pip3 install dynaport
importing
from dynaport.dynaport import Dynaport
functions
Dynaport(config="/path/to/config.json")
- instantiation of the Dynaport class, has an optional parameter
config
to load a config file. The config parameter can also take a dict as input. Needs to follow the same structure as the config file.
Dynaport.get_module(name="module_name", path="/path/to/module.py")
- loads and returns the module
Dynaport.get_modules(modules=["module1", "module2", "module3"], dict=True)
- loads and returns multiple modules as a tuple, optional
dict
param to load the modules into a dict. - NOTE: module names need to be unique or else they will be overwritten when creating the dict
Dynaport.get_config()
- returns the loaded config file
Dynaport.set_config(config=/path/to/config.json")
- same behavior as loading a config on instantiation
config file
Dynaport is able to use a json configuration file to define filepaths to modules you want to import.
The current format of the configuration file is as follows:
{
"modules": {
"module_name": "/path/to/module.py"
}
}
features
- all paths can have environment variables put in the path names. Windows can have %name% and Linux can have $name
future work
- add support for yaml files (but not require the dependency to be installed)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file dynaport-0.0.16.tar.gz
.
File metadata
- Download URL: dynaport-0.0.16.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1edce9ac3a839b8ad0e8ab3178bd29ea757bf6580249e38aa2e2d5a4675e6393 |
|
MD5 | f1c86ecc61d0a7cc98941a8b658ac886 |
|
BLAKE2b-256 | 4d34a76e825b1f83c57721c6f7bed32240557e87f9394a27da2b544b3d643240 |
File details
Details for the file dynaport-0.0.16-py3-none-any.whl
.
File metadata
- Download URL: dynaport-0.0.16-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/51.3.3 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fca94d138a31b10069db503256ab37f57c251dd415355a3a67b448b2ce67354 |
|
MD5 | 05d24019a45501d7ab41340f6518b0eb |
|
BLAKE2b-256 | 08334d4e3d2bd108ba668c6e64e4a54af65080bc9f2a57768001d4bfcacbd841 |