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
Hashes for dynaport-0.0.11-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6a60d2f3d805ca241301fcb9fc70ff09a5e9332dcf628afe7368287f7c9959bc |
|
MD5 | 24654892161448cf8e52562d671b8b71 |
|
BLAKE2b-256 | 7011b1757c47f64a0ea7ee04bbc742d59c7f111b4de4573b2dc6a5d004fa74af |