Skip to main content

Config data manager

Project description

Configg

Introduction

Simple wrapper module for reading/writing config data like a native python dictionary. Multiple backends provide an identical interface to various file formats (change one line to switch between json & xml).

Data is arranged into sections, and then by key:value pairs (like a traditional .ini file). This arrangement is consistent across all backends and file formats. Keys must be strings, and values must be strings or values (int, float etc).

Supported Backends

  • ini
  • xml
  • json
  • yml (planned)
  • sqlite3 (planned)

Usage

Here is an example ini config file, "myconfig.ini".

[user]
username = Peter
id = 5531274123

[database]
type = mongodb
ip = 12.34.56.78

Example loading myconfig.ini, and manipulating the data.

from configg import Configg, XML_BACKEND, JSON_BACKEND

# Instantiate Configg
cfg = Configg("myconfig.ini")

# Pull data from user section
username = cfg.user["username"]

# Add data to the user section
cfg.user["token"] = "apples"

# Pull data from the database section
db_ip = cfg.database["ip"]

# Add new section, with new data
cfg.add_section("app_settings", {"resolution": "1024x768"})

# Remove section
cfg.remove_section("app_settings")

# Commit local changes to file 
cfg.commit()

# Reload local data from file
cfg.reload()

# Create new xml config
cfg_xml = Configg("myconfig.xml", data_backend=XML_BACKEND)

# Create new xml config
cfg_json = Configg("myconfig.xml", data_backend=JSON_BACKEND)

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

configg-0.7b0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

configg-0.7b0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file configg-0.7b0.tar.gz.

File metadata

  • Download URL: configg-0.7b0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for configg-0.7b0.tar.gz
Algorithm Hash digest
SHA256 f0bd270b9e2f3c0d98631a4bdd3561f61b4d3efcfa2660f6eb38c90162d60596
MD5 6ffc4817cb9ea832c142986de05b20df
BLAKE2b-256 cd7ce8625bb7cb5dd87d0e99a96035f8a586015fe96dc87271a8f025670c763f

See more details on using hashes here.

File details

Details for the file configg-0.7b0-py3-none-any.whl.

File metadata

  • Download URL: configg-0.7b0-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for configg-0.7b0-py3-none-any.whl
Algorithm Hash digest
SHA256 90c2b107353785605818f71fb7bdd38e24d70802df38e41805c41d3ca2409902
MD5 779a4a9d44a26cdf7af3c07f27d1e7de
BLAKE2b-256 501f8cf8039c732188f7b115b1c6b75b2ce221e5fee58a2b787cc27809ba4d5e

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