Skip to main content

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
                       'space': ensure name = value format
                       'sectionspace': ensure one blank line between sections
                       '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

# Rewrite ini file to ensure a single blank line between sections,
# and no leading or trailing blank lines
  crudini --ini-options=sectionspace --set config_file ""

# 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.

On any system you should be able to pip install the latest code from github like:

pip install git+https://github.com/pixelb/crudini.git#egg=crudini

Metadata

Release files for crudini 0.9.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for crudini 0.9.6
File Size Uploaded
crudini-0.9.6.tar.gz 32.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for crudini 0.9.6
File Interpreter ABI Platform
crudini-0.9.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 56.8 kB

Release files / crudini-0.9.6.tar.gz

Download URL crudini-0.9.6.tar.gz
Size 32.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c2af311a0833857a1449d821a312edc6109f0c2d6d81d76c2d954a76b05e6b14
BLAKE2b-256 checksum
How to use checksums
54d10a363fbbab0aea9e27dd981a602efaf514c45f4fffceac3906274e0425c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release files / crudini-0.9.6-py2.py3-none-any.whl

Download URL crudini-0.9.6-py2.py3-none-any.whl
Size 24.0 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
b24bb97ee7b2d5f2142d4149170b734da824c9bd3b68317af0730871ae7b9a60
BLAKE2b-256 checksum
How to use checksums
c230c92dc8fe6bf310b9c5eadc22a6079c12902822d9d1ce72e833114484ed51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.2

Release history Release notifications | RSS feed

This release

0.9.6 This release

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page