Package: configparserenhanced
DEPRECATION NOTICE:This package was forked by the original author and
subdivided into separate packages:ConfigParserEnhanced⟶ActiveConfigParser:GitLabPyPIDocsDebuggable⟶LightweightDebugMessages:GitLabPyPIDocsExceptionControl⟶ExceptionControl:GitLabPyPIDocsTypedProperty⟶StronglyTypedProperty:GitLabPyPIDocsUsers ofConfigParserEnhancedshould switch to the new packages.ConfigParserEnhancedThe ConfigParserEnhanced (CPE) package provides extended
handling of .ini files beyond whatConfigParserprovides
by adding an active syntax to embed operations with options.For example, astandard.inifile is generally formatted like this:[Section 1]Foo:BarBaz:Bif[Section 2]Foo:Bar2Bif:BazThese 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 likehandler_<operation>().CPE only provides one pre-defined operation: use which is formatted asuse TARGET:whereparam1is the TARGET (there is no value field for this
one). The TARGET paramter takes thename of a target sectionthat will be
loaded in at this point. This works in the same way a#includewould
work in C++ and serves to insert the contents or processing of the
target section into this location.Theuseoperation 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 C1Key C2:Value C2Key C3:Value C3[Data 1]Key D1:Value D1use COMMONKey D2:Value D2In this example, processing sectionData 1via 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 theuseoperations are replaced with the
results of a Depth-First expansion of the linked sections:[COMMON]Key C1:Value C1Key C2:Value C2Key C3:Value C3[Data 1]Key D1:Value D1Key C1:Value C1Key C2:Value C2Key C3:Value C3Key D2:Value D2Linked ProjectsSetProgramOptions- depends on ConfigParserEnhancedRTD,GitHubExamplesHere we show some example usages of ConfigParserEnhanced.
Additional examples can be found in theexamples/directory
of the repository.Example 1[SECTION-A]key-A1:value-A1key-A2:value-A2key-A3:value-A3[SECTION-B]use SECTION-Akey-B1:value-B1In this example, the entryuse SECTION-Athat 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 parseSECTION-B.ConfigParserEnhanced.configparserenhanceddata['SECTION-B']would return the following
result:>>>fromconfigparserenhancedimportConfigParserEnhanced>>>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',}UpdatesSee theCHANGELOGfor information on changes.