Skip to main content

dkconfig - command line access to ConfigParser

Project description Documentation Status Coverage Status

dkconfig – command line access to ConfigParser

Installing from PyPI

pip install dkconfig

Basic usage

Most of the methods of ConfigParser ( 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
key = value

Sections can be added:

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


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

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


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%

Bash has a more sane syntax for this:

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

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

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

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

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for dkconfig, version 0.2.0
Filename, size File type Python version Upload date Hashes
Filename, size dkconfig-0.2.0-py2.py3-none-any.whl (9.3 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size dkconfig-0.2.0.tar.gz (5.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page