Skip to main content

ConfigParserEnhanced Testing Documentation Status

DEPRECATION NOTICE: This package was forked by the original author and subdivided into separate packages:

Users of ConfigParserEnhanced should switch to the new packages.

ConfigParserEnhanced

The ConfigParserEnhanced (CPE) package provides extended handling of .ini files beyond what ConfigParser provides by adding an active syntax to embed operations with options.

For example, a standard .ini file is generally formatted like this:

[Section 1]
Foo: Bar
Baz: Bif

[Section 2]
Foo: Bar2
Bif: Baz

These files are used to organize sets of key - value pairs called “options” within groups called “sections”. In the example above there are two sections, “Section 1” and “Section 2”. Each of them contains two options where Section 1 has the keys ‘Foo’ and ‘Baz’ which are assigned the values ‘Bar’ and ‘Bif’, respectively. For more details on .ini files please see the documentation for ConfigParser.

Internally, these handlers methods defined according to a naming convention like handler_<operation>().

CPE only provides one pre-defined operation: use which is formatted as use TARGET: where param1 is the TARGET (there is no value field for this one). The TARGET paramter takes the name of a target section that will be loaded in at this point. This works in the same way a #include would work in C++ and serves to insert the contents or processing of the target section into this location.

The use operation is useful for .ini files for complex systems by allowing developers to create a common section and then have specializations where they can customize options for a given project. For example:

[COMMON]
Key C1: Value C1
Key C2: Value C2
Key C3: Value C3

[Data 1]
Key D1: Value D1
use COMMON
Key D2: Value D2

In this example, processing section Data 1 via CPE will result in the following options: Key D1: Value D1, Key C1: Value C1, Key C2: Value C2, Key C2: Value C2, Key D2: Value D2.

An alternative way of looking at this is it’s like having a .ini file that is effectively the following where the use operations are replaced with the results of a Depth-First expansion of the linked sections:

[COMMON]
Key C1: Value C1
Key C2: Value C2
Key C3: Value C3

[Data 1]
Key D1: Value D1
Key C1: Value C1
Key C2: Value C2
Key C3: Value C3
Key D2: Value D2

Linked Projects

Examples

Here we show some example usages of ConfigParserEnhanced. Additional examples can be found in the examples/ directory of the repository.

Example 1

[SECTION-A]
key-A1: value-A1
key-A2: value-A2
key-A3: value-A3

[SECTION-B]
use SECTION-A
key-B1: value-B1

In this example, the entry use SECTION-A that is inside [SECTION-B] instructs the core parser to recurse into [SECTION-A] and process it before moving on with the rest of the entries in [SECTION-B]. In this example the following code could be used to parse SECTION-B. ConfigParserEnhanced.configparserenhanceddata['SECTION-B'] would return the following result:

>>> from configparserenhanced import ConfigParserEnhanced
>>> cpe = ConfigParserEnhanced(filename='config.ini')
>>> cpe.configparserenhanceddata['SECTION-B']
{
    'key-A1': 'value-A1',
    'key-A2': 'value-A2',
    'key-A3': 'value-A3',
    'key-B1': 'value-B1',
}

Updates

See the CHANGELOG for information on changes.

Metadata

Release files for configparserenhanced 0.8.1.5

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

Source distribution (sdist)

Source distribution for configparserenhanced 0.8.1.5
File Size Uploaded
configparserenhanced-0.8.1.5.tar.gz 55.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for configparserenhanced 0.8.1.5
File Interpreter ABI Platform
configparserenhanced-0.8.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 126.8 kB

Release files / configparserenhanced-0.8.1.5.tar.gz

Download URL configparserenhanced-0.8.1.5.tar.gz
Size 55.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f33aabe0ffcb8afca750bf6c3bfacf0094581b86b3d95d09f107ef049919edc8
BLAKE2b-256 checksum
How to use checksums
71706907145600fb8cd9755057ec39e04c292e455d34760ba2c6c75dc89769a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12

Release files / configparserenhanced-0.8.1.5-py3-none-any.whl

Download URL configparserenhanced-0.8.1.5-py3-none-any.whl
Size 71.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c68bd8f8e42114e0c002ebfb9efb5ac8ccb723a8702daa004858b58871948ae5
BLAKE2b-256 checksum
How to use checksums
b98b7d727b87750c9f0346334ee7b830d70d1640f7d0157ce4070e1063606d27
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.12
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