Skip to main content

dkconfig - command line access to ConfigParser

Project description

https://travis-ci.org/datakortet/dkconfig.svg?branch=master Documentation Status Coverage Status

dkconfig – command line access to ConfigParser

Installing from PyPI

pip install dkconfig

Basic usage

Most of the methods of ConfigParser (https://docs.python.org/2/library/configparser.html#ConfigParser.RawConfigParser) should be usable in a relatively obvious way, however, dkconfig tries to give you some sane defaults to make your life easier, e.g. it will create files/headers/keys that don’t exist:

/tst> ll
/tst> dkconfig foo.ini set header key value
/tst> cat foo.ini
[header]
key = value

Sections can be added:

/tst> dkconfig foo.ini add_section header2
/tst> cat foo.ini
[header]
key = value

[header2]

re-adding them is a no-op (and doesn’t throw an exception):

/tst> dkconfig foo.ini add_section header2
/tst> cat foo.ini
[header]
key = value

[header2]

the values command pretty prints the keys and values:

/tst> dkconfig foo.ini values
key => value

the dos command will output the key/values as dos set commands:

/tst> dkconfig foo.ini dos
set "KEY=value"

from a batch file you would use it like this:

dkconfig foo.ini dos > tmp.bat && call tmp.bat && del tmp.bat

the bash command does the same for bash, and you’ll use it together with eval:

eval $(dkconfig foo.ini bash)

You can read values directly into dos variables in the regular way:

> for /f "delims=" %a in ('dkconfig foo.ini get header key') do @set KEY=%a
> echo %KEY%
value

Bash has a more sane syntax for this:

bash$ export KEY=$(dkconfig foo.ini get header key)
bash$ echo $KEY
value

The appropriate error returns are set if a key is missing:

/tst> dkconfig foo.ini get header missing
/tst> echo %ERRORLEVEL%
1

/tst> dkconfig foo.ini get header key
value
/tst> echo %ERRORLEVEL%
0

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

dkconfig-0.2.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

dkconfig-0.2.1-py2.py3-none-any.whl (7.6 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file dkconfig-0.2.1.tar.gz.

File metadata

  • Download URL: dkconfig-0.2.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.5.4

File hashes

Hashes for dkconfig-0.2.1.tar.gz
Algorithm Hash digest
SHA256 93cd1de9c92eeddc29b59ce20c2066753d8aa43218906562625b7bae9a02285c
MD5 ebd79265000aad9b399927ef90d4e285
BLAKE2b-256 9a57ccfe5405f48f5f34f724d3a95790b9d0d8f8a8f0d2e8a1c5a0bf0da843f9

See more details on using hashes here.

File details

Details for the file dkconfig-0.2.1-py2.py3-none-any.whl.

File metadata

  • Download URL: dkconfig-0.2.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.5.4

File hashes

Hashes for dkconfig-0.2.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 17bdb1b80ac2e31359868eb31f99332af3e7d1339a7c487f017f9106924fd870
MD5 6c0675038c41e6e0134e7162aeb763cd
BLAKE2b-256 b3df4f8f270fbff308bae6f777e1abd4266a5dac9b0b22ad677b243bbfed6cda

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