configparserenhanced


Nameconfigparserenhanced JSON
Version 0.8.1.5 PyPI version JSON
download
home_pagehttps://github.com/sandialabs/ConfigParserEnhanced
SummaryA tool that extends configparser to enable enhanced processing of .ini files.
upload_time2023-10-29 04:57:43
maintainer
docs_urlNone
authorWilliam McLendon
requires_python>=3.6,<4.0
licenseLICENSE
keywords utility bash configuration configparserenhanced configparser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            <!-- Github Badges -->
[![ConfigParserEnhanced Testing](https://github.com/sandialabs/ConfigParserEnhanced/actions/workflows/test-driver-core.yml/badge.svg)](https://github.com/sandialabs/ConfigParserEnhanced/actions/workflows/test-driver-core.yml)
[![Documentation Status](https://readthedocs.org/projects/configparserenhanced/badge/?version=latest)](https://configparserenhanced.readthedocs.io/en/latest/?badge=latest)

> **DEPRECATION NOTICE:**  This package was forked by the original author and
> subdivided into separate packages:
>
> * `ConfigParserEnhanced` ⟶ `ActiveConfigParser`:
>   * [GitLab](https://gitlab.com/semantik-software/code/python/ActiveConfigParser)
>   * [PyPI](https://pypi.org/project/activeconfigparser/)
>   * [Docs](https://semantik-software.gitlab.io/code/python/ActiveConfigParser/)
> * `Debuggable` ⟶ `LightweightDebugMessages`:
>   * [GitLab](https://gitlab.com/semantik-software/code/python/LightweightDebugMessages)
>   * [PyPI](https://pypi.org/project/lightweightdebugmessages/)
>   * [Docs](https://semantik-software.gitlab.io/code/python/LightweightDebugMessages)
> * `ExceptionControl` ⟶ `ExceptionControl`:
>   * [GitLab](https://gitlab.com/semantik-software/code/python/ExceptionControl)
>   * [PyPI](https://pypi.org/project/exceptioncontrol/)
>   * [Docs](https://semantik-software.gitlab.io/code/python/ExceptionControl)
> * `TypedProperty` ⟶ `StronglyTypedProperty`:
>   * [GitLab](https://gitlab.com/semantik-software/code/python/StronglyTypedProperty)
>   * [PyPI](https://pypi.org/project/stronglytypedproperty/)
>   * [Docs](https://semantik-software.gitlab.io/code/python/StronglyTypedProperty)
>
> Users of `ConfigParserEnhanced` should switch to the new packages.

ConfigParserEnhanced
====================

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

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

```ini
[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:

```ini
[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:

```ini
[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
---------------
- [SetProgramOptions][3] - depends on ConfigParserEnhanced [RTD][4], [GitHub][5]

Examples
--------
Here we show some example usages of ConfigParserEnhanced.
Additional examples can be found in the [`examples/`](examples) directory
of the repository.

### Example 1

```ini
[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:

```python
>>> 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][2] for information on changes.


[1]: https://docs.python.org/3/library/configparser.html
[2]: https://github.com/sandialabs/ConfigParserEnhanced/blob/master/CHANGELOG.md
[3]: https://pypi.org/project/setprogramoptions/
[4]: https://setprogramoptions.readthedocs.io/en/latest
[5]: https://github.com/sandialabs/SetProgramOptions


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sandialabs/ConfigParserEnhanced",
    "name": "configparserenhanced",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6,<4.0",
    "maintainer_email": "",
    "keywords": "Utility,Bash,Configuration,ConfigParserEnhanced,ConfigParser",
    "author": "William McLendon",
    "author_email": "wcmclen@sandia.gov",
    "download_url": "https://files.pythonhosted.org/packages/71/70/6907145600fb8cd9755057ec39e04c292e455d34760ba2c6c75dc89769a5/configparserenhanced-0.8.1.5.tar.gz",
    "platform": null,
    "description": "<!-- Github Badges -->\n[![ConfigParserEnhanced Testing](https://github.com/sandialabs/ConfigParserEnhanced/actions/workflows/test-driver-core.yml/badge.svg)](https://github.com/sandialabs/ConfigParserEnhanced/actions/workflows/test-driver-core.yml)\n[![Documentation Status](https://readthedocs.org/projects/configparserenhanced/badge/?version=latest)](https://configparserenhanced.readthedocs.io/en/latest/?badge=latest)\n\n> **DEPRECATION NOTICE:**  This package was forked by the original author and\n> subdivided into separate packages:\n>\n> * `ConfigParserEnhanced` \u27f6 `ActiveConfigParser`:\n>   * [GitLab](https://gitlab.com/semantik-software/code/python/ActiveConfigParser)\n>   * [PyPI](https://pypi.org/project/activeconfigparser/)\n>   * [Docs](https://semantik-software.gitlab.io/code/python/ActiveConfigParser/)\n> * `Debuggable` \u27f6 `LightweightDebugMessages`:\n>   * [GitLab](https://gitlab.com/semantik-software/code/python/LightweightDebugMessages)\n>   * [PyPI](https://pypi.org/project/lightweightdebugmessages/)\n>   * [Docs](https://semantik-software.gitlab.io/code/python/LightweightDebugMessages)\n> * `ExceptionControl` \u27f6 `ExceptionControl`:\n>   * [GitLab](https://gitlab.com/semantik-software/code/python/ExceptionControl)\n>   * [PyPI](https://pypi.org/project/exceptioncontrol/)\n>   * [Docs](https://semantik-software.gitlab.io/code/python/ExceptionControl)\n> * `TypedProperty` \u27f6 `StronglyTypedProperty`:\n>   * [GitLab](https://gitlab.com/semantik-software/code/python/StronglyTypedProperty)\n>   * [PyPI](https://pypi.org/project/stronglytypedproperty/)\n>   * [Docs](https://semantik-software.gitlab.io/code/python/StronglyTypedProperty)\n>\n> Users of `ConfigParserEnhanced` should switch to the new packages.\n\nConfigParserEnhanced\n====================\n\nThe ConfigParserEnhanced (CPE) package provides extended\nhandling of .ini files beyond what [ConfigParser][1] provides\nby adding an active syntax to embed operations with options.\n\nFor example, a *standard* `.ini` file is generally formatted like this:\n\n```ini\n[Section 1]\nFoo: Bar\nBaz: Bif\n\n[Section 2]\nFoo: Bar2\nBif: Baz\n```\n\nThese files are used to organize sets of key - value pairs called\n\u201coptions\u201d within groups called \u201csections\u201d. In the example above\nthere are two sections, \u201cSection 1\u201d and \u201cSection 2\u201d. Each of them\ncontains two options where Section 1 has the keys \u2018Foo\u2019 and \u2018Baz\u2019\nwhich are assigned the values \u2018Bar\u2019 and \u2018Bif\u2019, respectively. For\nmore details on .ini files please see the documentation for\nConfigParser.\n\nInternally, these handlers methods defined according to a naming\nconvention like `handler_<operation>()`.\n\nCPE only provides one pre-defined operation: use which is formatted as\n`use TARGET:` where *param1* is the TARGET (there is no value field for this\none). The TARGET paramter takes the *name of a target section* that will be\nloaded in at this point. This works in the same way a `#include` would\nwork in C++ and serves to insert the contents or processing of the\ntarget section into this location.\n\nThe `use` operation is useful for .ini files for complex systems by allowing\ndevelopers to create a common section and then have specializations where\nthey can customize options for a given project. For example:\n\n```ini\n[COMMON]\nKey C1: Value C1\nKey C2: Value C2\nKey C3: Value C3\n\n[Data 1]\nKey D1: Value D1\nuse COMMON\nKey D2: Value D2\n```\n\nIn this example, processing section `Data 1` via CPE will result in\nthe following options: `Key D1: Value D1`, `Key C1: Value C1`,\n`Key C2: Value C2`, `Key C2: Value C2`, `Key D2: Value D2`.\n\nAn alternative way of looking at this is it\u2019s like having a .ini file that\nis effectively the following where the `use` operations are replaced with the\nresults of a Depth-First expansion of the linked sections:\n\n```ini\n[COMMON]\nKey C1: Value C1\nKey C2: Value C2\nKey C3: Value C3\n\n[Data 1]\nKey D1: Value D1\nKey C1: Value C1\nKey C2: Value C2\nKey C3: Value C3\nKey D2: Value D2\n```\n\nLinked Projects\n---------------\n- [SetProgramOptions][3] - depends on ConfigParserEnhanced [RTD][4], [GitHub][5]\n\nExamples\n--------\nHere we show some example usages of ConfigParserEnhanced.\nAdditional examples can be found in the [`examples/`](examples) directory\nof the repository.\n\n### Example 1\n\n```ini\n[SECTION-A]\nkey-A1: value-A1\nkey-A2: value-A2\nkey-A3: value-A3\n\n[SECTION-B]\nuse SECTION-A\nkey-B1: value-B1\n```\n\nIn this example, the entry `use SECTION-A` that is inside `[SECTION-B]` instructs the core\nparser to recurse into `[SECTION-A]` and process it before moving on with the rest of the\nentries in `[SECTION-B]`.  In this example the following code could be used to parse\n`SECTION-B`.\n`ConfigParserEnhanced.configparserenhanceddata['SECTION-B']` would return the following\nresult:\n\n```python\n>>> from configparserenhanced import ConfigParserEnhanced\n>>> cpe = ConfigParserEnhanced(filename='config.ini')\n>>> cpe.configparserenhanceddata['SECTION-B']\n{\n    'key-A1': 'value-A1',\n    'key-A2': 'value-A2',\n    'key-A3': 'value-A3',\n    'key-B1': 'value-B1',\n}\n```\n\nUpdates\n=======\nSee the [CHANGELOG][2] for information on changes.\n\n\n[1]: https://docs.python.org/3/library/configparser.html\n[2]: https://github.com/sandialabs/ConfigParserEnhanced/blob/master/CHANGELOG.md\n[3]: https://pypi.org/project/setprogramoptions/\n[4]: https://setprogramoptions.readthedocs.io/en/latest\n[5]: https://github.com/sandialabs/SetProgramOptions\n\n",
    "bugtrack_url": null,
    "license": "LICENSE",
    "summary": "A tool that extends configparser to enable enhanced processing of .ini files.",
    "version": "0.8.1.5",
    "project_urls": {
        "CI": "https://github.com/sandialabs/ConfigParserEnhanced/actions/workflows/test-driver-core.yml",
        "Documentation": "https://configparserenhanced.readthedocs.io/en/latest/",
        "Homepage": "https://github.com/sandialabs/ConfigParserEnhanced",
        "Issues": "https://github.com/sandialabs/ConfigParserEnhanced/issues",
        "Repository": "https://github.com/sandialabs/ConfigParserEnhanced"
    },
    "split_keywords": [
        "utility",
        "bash",
        "configuration",
        "configparserenhanced",
        "configparser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b98b7d727b87750c9f0346334ee7b830d70d1640f7d0157ce4070e1063606d27",
                "md5": "465e91e501de84e0f7f4b1403a88d37e",
                "sha256": "c68bd8f8e42114e0c002ebfb9efb5ac8ccb723a8702daa004858b58871948ae5"
            },
            "downloads": -1,
            "filename": "configparserenhanced-0.8.1.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "465e91e501de84e0f7f4b1403a88d37e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6,<4.0",
            "size": 71076,
            "upload_time": "2023-10-29T04:57:41",
            "upload_time_iso_8601": "2023-10-29T04:57:41.165755Z",
            "url": "https://files.pythonhosted.org/packages/b9/8b/7d727b87750c9f0346334ee7b830d70d1640f7d0157ce4070e1063606d27/configparserenhanced-0.8.1.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "71706907145600fb8cd9755057ec39e04c292e455d34760ba2c6c75dc89769a5",
                "md5": "6ce4f3a2de419ada334bec0c8bc65ac7",
                "sha256": "f33aabe0ffcb8afca750bf6c3bfacf0094581b86b3d95d09f107ef049919edc8"
            },
            "downloads": -1,
            "filename": "configparserenhanced-0.8.1.5.tar.gz",
            "has_sig": false,
            "md5_digest": "6ce4f3a2de419ada334bec0c8bc65ac7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6,<4.0",
            "size": 55764,
            "upload_time": "2023-10-29T04:57:43",
            "upload_time_iso_8601": "2023-10-29T04:57:43.538452Z",
            "url": "https://files.pythonhosted.org/packages/71/70/6907145600fb8cd9755057ec39e04c292e455d34760ba2c6c75dc89769a5/configparserenhanced-0.8.1.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-29 04:57:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sandialabs",
    "github_project": "ConfigParserEnhanced",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [],
    "lcname": "configparserenhanced"
}
        
Elapsed time: 0.13303s