Skip to main content

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


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.5.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

mpcspy-0.0.5-py3.8.egg (5.7 kB view details)

Uploaded Source

File details

Details for the file mpcspy-0.0.5.tar.gz.

File metadata

  • Download URL: mpcspy-0.0.5.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.4.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for mpcspy-0.0.5.tar.gz
Algorithm Hash digest
SHA256 3ade4d432346561eb0ecbd83522071b86d0528964fa19cf14ff6168b17a77665
MD5 982e8eb32e54a4a3f3727ebd0f998f1a
BLAKE2b-256 f6f461e17570fbbb5582c7bdfe30236657629bd3d1560dece4c81da854588a6d

See more details on using hashes here.

Provenance

File details

Details for the file mpcspy-0.0.5-py3.8.egg.

File metadata

  • Download URL: mpcspy-0.0.5-py3.8.egg
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.4.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for mpcspy-0.0.5-py3.8.egg
Algorithm Hash digest
SHA256 5930109bbccee7e00cf42de147a550a56ce5adbd901ebd930b92289293048fb7
MD5 637c612d934bacc2c4a6e433d0e0212c
BLAKE2b-256 414757e0ef241c292e6ea36dd56eb05de97119541a7e12d2b52c73b302041c04

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page