Skip to main content

A utility for manipulating ini files

Project description

crudini - A utility for manipulating ini files

Usage:

crudini --set [OPTION]...   config_file section   [param] [value]
crudini --get [OPTION]...   config_file [section] [param]
crudini --del [OPTION]...   config_file section   [param] [list value]
crudini --merge [OPTION]... config_file [section]

SECTION can be empty ("") or "DEFAULT" in which case,
params not in a section, i.e. global parameters are operated on.
If 'DEFAULT' is used with --set, an explicit [DEFAULT] section is added.

Multiple --set|--del|--get operations for a config_file can be specified.

Options:


  --existing[=WHAT]  For --set, --del and --merge, fail if item is missing,
                       where WHAT is 'file', 'section', or 'param',
                       or if WHAT not specified; all specified items.
  --format=FMT       For --get, select the output FMT.
                       Formats are 'sh','ini','lines'
  --ini-options=OPT  Set options for handling ini files.  Options are:
                       'nospace': use format name=value not name = value
                       'ignoreindent': ignore leading whitespace
  --inplace          Lock and write files in place.
                       This is not atomic but has less restrictions
                       than the default replacement method.
  --list             For --set and --del, update a list (set) of values
  --list-sep=STR     Delimit list values with "STR" instead of " ,".
                       An empty STR means any whitespace is a delimiter.
  --output=FILE      Write output to FILE instead. '-' means stdout
  --verbose          Indicate on stderr if changes were made
  --help             Write this help to stdout
  --version          Write version to stdout

Examples:


# Add/Update a var
  crudini --set config_file section parameter value

# Add/Update a var in the root or global area.
# I.e. that's not under a [section].
  crudini --set config_file "" parameter value

# Update an existing var
  crudini --set --existing config_file section parameter value

# Add/Update/Delete multiple variables atomically
  crudini --set config_file section parameter1 value \
          --set config_file section parameter2 value \
          --del config_file section parameter3

# Get multiple items from stdin
  env | crudini --get - '' USER --get - '' SHELL

# Add/Append a value to a comma separated list
# Note any whitespace around commas is ignored
  crudini --set --list config_file section parameter a_value

# Add/Append a value to a whitespace separated list
# Note multiline lists are supported (as newline is whitespace)
  crudini --set --list --list-sep= config_file section parameter a_value

# Delete a var
  crudini --del config_file section parameter

# Delete a section
  crudini --del config_file section

# output a value
  crudini --get config_file section parameter

# output a global value not in a section
  crudini --get config_file "" parameter

# output a section
  crudini --get config_file section

# output a section, parseable by shell
  eval "$(crudini --get --format=sh config_file section)"

# update an ini file from shell variable(s)
  echo name="$name" | crudini --merge config_file section

# merge an ini file from another ini
  crudini --merge config_file < another.ini

# compare two ini files using standard UNIX text processing
  diff <(crudini --get --format=lines file1.ini|sort) \
       <(crudini --get --format=lines file2.ini|sort)

# Rewrite ini file to use name=value format rather than name = value
  crudini --ini-options=nospace --set config_file ""

# Add/Update a var, ensuring complete file in name=value format
  crudini --ini-options=nospace --set config_file section parameter value

# Read indented ini file, like .gitconfig
  crudini --ini-options=ignoreindent --format=lines --get ~/.gitconfig

Installation

On windows ensure a python interpreter is installed. For example installing from https://www.python.org/downloads/ will put the py launcher and pip in the PATH.

Then ensure the iniparse module is installed by running the following from a "cmd" prompt:

pip install iniparse

Then crudini can be invoked by downloading just the crudini.py file and running like:

py crudini.py --help

On Linux systems crudini is generally available from your standard package manager, and installing will also ensure the iniparse dependency is appropriately installed on your system. You can also download and run the single crudini.py file directly to use latest version.

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

crudini-0.9.5.tar.gz (31.0 kB view details)

Uploaded Source

Built Distribution

crudini-0.9.5-py2.py3-none-any.whl (23.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file crudini-0.9.5.tar.gz.

File metadata

  • Download URL: crudini-0.9.5.tar.gz
  • Upload date:
  • Size: 31.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.5

File hashes

Hashes for crudini-0.9.5.tar.gz
Algorithm Hash digest
SHA256 59ae650f45af82a64afc33eb876909ee0c4888dc4e8711ef59731c1edfda5e24
MD5 65db5752000a9c95c35f0b047e670dcb
BLAKE2b-256 3267c4e838930e2f434db08d6a6aadffca3d14e7455d1c2c2332e22003ad453d

See more details on using hashes here.

File details

Details for the file crudini-0.9.5-py2.py3-none-any.whl.

File metadata

  • Download URL: crudini-0.9.5-py2.py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.11.5

File hashes

Hashes for crudini-0.9.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 84bc208dc7d89571bdc3c99274259d0b32d6b3a692d4255524f2eb4b64e9195c
MD5 d5b7bc8ca8da55ca0521859b0154f526
BLAKE2b-256 c52be7e1ed429b1122c2c649c4b47b5f80efeea5d7531418a8bd1bd9f994ff16

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