My Personal Configuration System for Python
Project description
My Personal Configuration System for Python MPCSPY
I like to use Python as a configuration file. I have added some security features using AST module to prevent injecting malicious code to config files.
Requirements
- Python >= 3.6 (fstrings)
Install
PyPI
pip3 install mpcspy
Source
git clone https://github.com/goktug97/mpcspy
cd mpcspy
python3 setup.py install
Example
- Config File
#!/usr/bin/env python3 import dataclasses import numpy as np @dataclasses.dataclass class Robot(object): width: float = 1.2 # [m] height: float = 0.5 # [m] max_angular_velocity: float = np.radians(40.0) # [rad/s]
- Reading Config
import mpcspy config = mpcspy.read_config(config_file = 'config', allowed_modules={'numpy': ['radians'], 'dataclasses': ['dataclass']}, allowed_functions=[], verbose=True) print(config.Robot.width) print(config.Robot.height) print(config.Robot.max_angular_velocity)
- Config File
#!/usr/bin/env python3 from os import path dataset_path = path.join('./data/')
- Reading Config
import mpcspy config = mpcspy.read_config(config_file = 'config', allowed_modules={'os': ['path'], 'path': ['join']}, allowed_functions=[], verbose=True)
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.
Filename, size | File type | Python version | Upload date | Hashes |
---|---|---|---|---|
Filename, size mpcspy-0.0.5-py3.8.egg (5.7 kB) | File type Egg | Python version 3.8 | Upload date | Hashes View |
Filename, size mpcspy-0.0.5.tar.gz (3.3 kB) | File type Source | Python version None | Upload date | Hashes View |