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.
Source Distribution
mpcspy-0.0.3.tar.gz
(3.3 kB
view details)
Built Distribution
mpcspy-0.0.3-py3.8.egg
(5.6 kB
view details)
File details
Details for the file mpcspy-0.0.3.tar.gz
.
File metadata
- Download URL: mpcspy-0.0.3.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b54dfa62dc020f33f683181a5e0bc4cb4f750d1effd9baffeae27a3bbae8d67 |
|
MD5 | 632ab99bc13a57e8df3755bcdd85117d |
|
BLAKE2b-256 | d8fd32db8f33710a1681b7245453b38e35cac96813b82a7cbea9da0bab2210e0 |
Provenance
File details
Details for the file mpcspy-0.0.3-py3.8.egg
.
File metadata
- Download URL: mpcspy-0.0.3-py3.8.egg
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.8.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 779f49a45eff0ee7284e749b0f979a5dfde7320cf22f6ef7a0fef0ee3712e89d |
|
MD5 | 6c8ff5df590d87c34d89eb66fdd85c08 |
|
BLAKE2b-256 | da18cd7d031a43df8c56c1b40235a4c4606eeaa45ee2a17d003ed6c7f38952d2 |