Skip to main content

Dead simple configuration file parser.

Project description

https://travis-ci.org/kisom/pysimpleconfig.svg?branch=master

what?

simpleconfig is a Python module that reads INI files into a dictionary. It is both Python 2 and Python 3 compatible.

why?

I’ve written this code several times for a couple projects; I got sick of copying the file over to new project directories.

how?

Both a parse and parse_string function are provided. The former parses config files, and the latter parses a config file serialised into a string.

return value and example

Both parse() and parse_string return a dictionary (see below) where each section is a key at the top level, and is a dictionary of key=value pairs itself. For example, given the config file:

>>> config = """
# random version information
version = 1.0.5

; last modified 1 April 2001 by John Doe
; example taken from wikipedia
[owner]
name=John Doe
organization=Acme Widgets Inc.

[database]
# use IP address in case network name resolution is not working
server=192.0.2.62
port=143
file="payroll.dat"
"""

Parsing this with simpleconfig yields:

>>> import simpleconfig as sc
>>> cfg = sc.parse_string(config)
>>> cfg['owner']['name']
'John Doe'
>>> cfg.owner.name
'John Doe'

Note that the dictionary type returned by the parse functions is actually a kutils.dicts.AttrDictDict, which is derived from the dict type and can be used wherever a dict can.

license

simpleconfig is released under an ISC license.

author

simpleconfig was written by Kyle Isom <coder@kyleisom.net>.

additional

The module is only tested for compatibility against Python 2.7 and Python 3.3+. There are no guarantees (or attempts) at compatibility with previous version of Python.

The docs are on RTD.

The source for simpleconfig is online:

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

simpleconfig-2.0.tar.gz (2.6 kB view details)

Uploaded Source

Built Distributions

simpleconfig-2.0-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

simpleconfig-2.0-py2-none-any.whl (4.9 kB view details)

Uploaded Python 2

File details

Details for the file simpleconfig-2.0.tar.gz.

File metadata

  • Download URL: simpleconfig-2.0.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for simpleconfig-2.0.tar.gz
Algorithm Hash digest
SHA256 c237d528a71218a20d9c3f85d4b37e03d628ee9effe501e180a378f903c649e8
MD5 5e9e776bd6844d51055455b58443b8b2
BLAKE2b-256 1649e7df279b3cae25790f32d495e519a568102cada5a4f0c409219b683e0ee7

See more details on using hashes here.

File details

Details for the file simpleconfig-2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for simpleconfig-2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39ef3997931572c8365fb65fdc31686f1f91554d5ffb1025563a1df695b66f81
MD5 d1b50bc62d3df9bd82506ffefed3e1a5
BLAKE2b-256 6fe21ff596a21a89ffa73c66f01db8a82a200944bbeec4ea4ae1970d0ddddaa7

See more details on using hashes here.

File details

Details for the file simpleconfig-2.0-py2-none-any.whl.

File metadata

File hashes

Hashes for simpleconfig-2.0-py2-none-any.whl
Algorithm Hash digest
SHA256 29301670b95e3b47d78d123c4f0d89cd0f44b5d46e5ff8d95ba051c9d5d6d404
MD5 e1e1f0860e579b875cf89d7cf50e2653
BLAKE2b-256 56a0b9d7200088a421f25007ef15811b4bb26f2339e3d6a6d0e6ff4587a12059

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