iniget
A command-line tool to extract, normalize, and JSONify values from an iniherit -enabled "INI" file.
Installation
$ pip install inigetUsage
Given the following two files, base.ini:
[sect1]
foo = barand config.ini:
[DEFAULT]
%inherit = base.iniThe following will extract the inherited foo value:
$ iniget config.ini sect1 foo
barMuch more is possible, including:
- listing sections
- listing options
- JSON-encoding the configuration
- JSON-interpreting option values
- Control case-sensitivity, interpolation, and default values
Options
-
-s SECTION, --section SECTIONSpecify additional sections to extract from; can be specified multiple times to add multiple sections.
-
-C, --no-caseHandle option names case insensitively.
-
-I, --no-inheritDisable processing of "%inherit" directives.
-
-E, --no-expansionDisable ConfigParser option expansion ("interpolation").
-
-F, --no-fallbackDisables falling back to the raw option value when an option value cannot be interpolated (this generally happens when it is incorrectly formatted or it references undefined substitutions), and causes an exception to be thrown.
-
-K, --list-optionsList the option names only, not the values.
-
-S, --list-sectionsList the section names only.
-
-J, --json-parseIf option values are JSON-parseable, parse as such; additionally, the following are interpreted as boolean values: 'yes', 'true', 'on', 'off', 'no', 'false'.
-
-j, --json-outputRender the output using JSON syntax.
-
-d JSON, --defaults JSONSet the ConfigParser default values from this JSON-parsed dictionary.
-
-r, --rawDon't do anything fancy: show exactly what ConfigParser interprets (requires exactly one section and one option); note that options "--no-case", "--no-inherit", "--no-expansion" and "--defaults" are still honored, but "--json-parse" is not.