Skip to main content

Small package for working with config files

Project description

config manager

Installation:

pip install manageconfig

This library manages config files and exposes them as Python objects. It is super small, basic, and easy to use.

Note: This package currently supports only YAML and JSON configurations, but we will soon add support for other formats (and we are open to suggestions).

Example:

Suppose we want to load the config.py file attached below. We can do it as follows:

from manageconfig import Config

conf = Config.load_from_yml('config.yml')

print(conf.string2)
print(conf.string1)

# This will print 'localhost'
print(conf.mysqldatabase.hostname)

# i == 3013
i = conf.mysqldatabase.port + 1
# comment syntax

# basic syntax - key and value separated by colon and space before the value
key: value

# Scalar data types
integerValue: 1                     # integer value
floatingValue: 1                     # floating vale

stringValue: "456"                   # string with double quotes
stringValue: 'abc'                  # string with single quotes
stringValue: wer                   # string without quotes

booleanValue: true                   # boolean values - true or false


# Multiline string with literal block syntax -preserved new lines
string1: |
  Line1
  line2
  "line3"
  line4

# Multiline strings with folded block syntax - new lines are not preserved, 
# leading and trailing spaces are ignore
string2: >
  Line1
  line2
  "line3"
  line4
# Collection sequence data types
# sequence arraylist example
arraylist:
  - One
  - two
  - Three

arraylist2: [one, two , three]

mysqldatabase:
  hostname: localhost
  port: 3012
  username: root
  password: root

JSON support: In order to use json format - simply use Config.load_from_json('config.json')

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

manageconfig-1.1.1.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

manageconfig-1.1.1-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file manageconfig-1.1.1.tar.gz.

File metadata

  • Download URL: manageconfig-1.1.1.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.6

File hashes

Hashes for manageconfig-1.1.1.tar.gz
Algorithm Hash digest
SHA256 f5d8d6463ddf68d9d4c145f6958517d8be382bd977f4c116f44c89a495d27dda
MD5 56b118ddc2a966c3a729866fa4f5e263
BLAKE2b-256 66f70a88fdcdb1e2b2be388812d175f85e09cbf9e07eb948b92ca6ee72653b4a

See more details on using hashes here.

File details

Details for the file manageconfig-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for manageconfig-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 44d85dc44a1537f60a806b6ac840f6526076b77fbc65a93e6f085796864600c1
MD5 d5956df1ec108929923ae8028a0de37c
BLAKE2b-256 b6003c407a1a2963366f26b495f4ab0f1346699bca62b42a5200936a1c575210

See more details on using hashes here.

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