All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- CPE : Short for
ConfigParserEnhanced
.
- Add deprecation notice to the docs
- Remove maintainer contact info
- Redirect users to
ActiveConfigParser
and its dependencies
- Documentation cleanup.
- Minor documentation cleanup for distribution.
- Updating documentation to a standard that's good for distribution on PyPi, Github, and Read The Docs.
- OSS License approval
- Using 3-Clause BSD license.
- Added LICENSE.md
- Added License headers to source files.
- Github Actions Script (initial testing)
- Added some docstring updates.
- Changed the require set before use restriction on
parse_section_last_result
that usesTypedProperty
since this seemed to trigger an error in the insection part ofget_known_operations()
. I'm not sure why inspection would do that at this time and it'll need a bit of investigation. Probably we need to implement a propergetter
in TypedProperty and apply those checks there.
- Added the list of file(s) that are loaded to the error message in the validator
functions:
assert_file_all_sections_handled
,assert_section_all_options_handled
- Fixed a bug in the list comprehension in
get_known_operations()
and added a test to make sure it's doing the right thing.
get_known_operations()
- Generate a list of known operations based on defined handlers.
get_known_operations_message()
- Generate a message listing known operations generated by
get_known_operations()
.
- Generate a message listing known operations generated by
assert_section_all_options_handled()
- Enable a check that there are no unhandled options within a specific section of a .ini file.
assert_file_all_sections_handled()
- Enable a check that there are no unhandled options in any section of a .ini file
_tokenize_option_key()
- A parser helper used for processng options into possible operations
_get_op_components_from_tokenized_option_key()
- A parser helper used for processng options into possible operations
- Updated
.style.yapf
andexec-reformat.sh
and ran a pass through the code to do a formatting pass. - Added Python 3.6.x check to
ConfigParserEnhanced.py
- Changed many strings to use f-strings instead of
.format()
(requires Python 3.6)
- property:
default_section_name
- parameterizes the CPE's version of the "DEFAULT" section. This defaults to "DEFAULT" and will get loaded in once at the start a new parse of a section.
- Relocated the
configparserenhanced
directory intosrc/configparserenhanced
and adjusted documentation, testing, etc. files to work with this new structure. - The logic for
TypedProperty
validator functions is reversed. Falsy results mean failure now and truthy results indicate a successful validation of a value.
- Performed a style refactoring pass.
- Added a
.style.yapf
file with a reasonable looking set of specifications.
- Added a
- removed testing requirements from the
requirements.txt
file and put them in a new file,requirements-test.txt
. - cleaned up output from the
exec-tests.sh
file to now put log info in files named_test-XXX.log
- property:
_internal_default_section_name
- parameterizes the internal ConfigParser object's DEFAULT section to a nonstandard value (CONFIGPARSERENHANCED_COMMON
). This section name should generally be avoided in .ini files as it can cause undefined behavior in CPE's recursive search when there areuse
operations present. This is because ConfigParser's DEFAULT section will be prepended to each section processed. This will invalidate any changes made in a CPE section to a value set in the default.
- Added a
default_factory
to theTypedProperty
utility for when the default value is too complex to usedeepcopy
and we need to use some kind of generator.
operation_handler
decorator- Enables the creation of handlers using decorators. For example:
@operation_handler def handler_myop(self, section_name, handler_parameters): # do stuff return 0
- Enables the creation of handlers using decorators. For example:
__repr__()
added toConfigParserEnhanced.ConfigParserEnhancedData
TypedProperty
: implements adataclass
pattern that allows the generation of "typed" properties generally following and extending the pattern outlined in "9.21 Avoiding Repetitive Property Methods" from the O'Reilly "Python Cookbook, 3rd Edition" (https://learning.oreilly.com/library/view/python-cookbook-3rd/9781449357337/)
- HandlerParameters is modified to use
TypedProperty.typed_property
pattern to define properties.
-->
- Method: Add new method,
write()
. This is a wrapper tounroll_to_str()
which writes the output to a file pointer. We included this function to provide a familiar interface toConfigParserEnhanced
as theConfigParser.write()
method. - Method: Add new method,
unroll_to_str()
. This generates astr
containing a parsed copy of the.ini
file in which all handled options are stripped out leaving the regular key:value pairs remaining. The effect of this is to generate a string containing the transitive-closure of each section's options after all theuse
operations have been processed. - ExceptionControl: Added new event type
SILENT
, which will throw its exception at the same level of aWARNING
but will never print a warning message to stdout. - ConfigParserEnhanced property:
configparser_delimiters
which exposes the ability to modify the delimiters in the underlyingConfigParser
parser for .ini files. Default value is('=',':')
and it allows assignment as a list, tuple, or str but gets converted to a tuple internally. - Internal helper method
_locate_class_method(method_name)
which finds a class method if it is defined.
Removed the regular expression based splitting method for keys into tokens
for the use of shlex.split
, which looks to do a better job of extracting
tokens in the manner we would like without requiring a complex REGEX.
HandlerParameters was also changed to remove op_params
in favor of two new
properties: op
and params
, where op
is a string and params
is a list
of strings.
- HandlerParams property:
HandlerParams.op
- HandlerParams property:
HandlerParams.params
- ConfigParserEnhanced method:
ConfigParserEnhanced._regex_splitter()
- ConfigParserEnhanced method:
ConfigParserEnhanced._regex_op_matcher()
- ConfigParserEnhanced method:
ConfigParserEnhanced._get_op1_from_regex_match()
- ConfigParserEnhanced method:
ConfigParserEnhanced._get_op2_from_regex_match()
- HandlerParameters property :
HandlerParams.op_params
- Issue #10: Bugfix: dots
.
in section names confused theuse
command.
- Add
_validate_parameter
internal function to wrap the parameter check operation that we do around the code. This simplifies some of the coverage issues and also makes it easier to put more type checks around parameters.
ConfigParserEnhanced.parse_all_sections()
added as a shortcut to kick off a full parse of ALL sections in the .ini file.
- Changed
ConfigParserEnhancedData.data
property to include an empty "DEFAULT" section if none is provided by the .ini file. This is to maintain compatibility withConfigParser
. - Changed
ConfigParserEnhancedData.get(section, option)
toConfigParserEnhancedData::get(section, option=None)
. Nowoption
can be an optional parameter and will return adict
containing the section's keys if only asection
is provided.
- New private method:
_loginfo_reset
. This removes the_loginfo
attribute. - New internal method
_apply_transformation_to_operation()
. Applies any needed transformations to the raw<operation>
strings. Currently this just replaces occurrences of-
with_
to operations. - New internal method
_apply_transformation_to_parameter()
. Applies any needed transformations to the raw<parameter>
strings. Currently this is just a pass-through, added now to pair with_apply_transformation_to_operation()
.
- Add parameter
parse
toConfigParserEnhancedData.sections
which can be eitherTrue
,False
, or"force"
.- If
False
then requestingconfigparserenhanceddata.sections()
will give the list of sections in the .ini file without parseing them. - If
True
then requestingconfigparserenhanceddata.sections()
will give the list of sections in the .ini file but it will also kick off the parser to parse (and cache) them. - If
"force"
then requestingconfigparserenhanceddata.sections()
will FORCE a (re)parse of the sections in the .ini file.
- If
- Add parameter
force_parse
toConfigParserEnhancedData._parse_owner_sections()
in support of newparse
parameter toConfigParserEnhancedData.sections
. operations
have added processing to do some normalization. Currently this is just a replacement of any-
with_
. For example, an operation such asfoo-bar-baz
will be converted tofoo_bar_baz
internally.
- Fix a bug in the indexing in the
ExceptionControl
module to print out the correct stack entry showing whereexception_control_event
was called that triggered the event in the traceback whenexception_control_compact_warnings
is enabled.
ExceptionControl
- Add property
_exception_control_map_event_to_level_req
toExceptionControl
which maps the exception control levels to the type names. - Add new class of
exception_control_event
: "CATASTROPHIC" which indicates errors that will always raise the exception and cannot be overridden.
- Add property
- Added property
exception_control_silent_warnings
toExceptionControl
to enable silencing events that would only print out a warning message. - Added property
exception_control_compact_warnings
toExceptionControl
to enable compact one-line warning messages instead of the full message and stack trace that is normally generated. - Renamed
generic_handler
to_generic_option_handler
because that name could inadvertantly cause a.ini
file option such asgeneric command: should not invoke a handler
to invoke thegeneric_handler
but it would go through the handled operation code path and not the true generic command code path.
- New property to
ConfigParserEnhanced
:parse_section_last_result
. This property gives access to the results from the last call toparse_section()
.
ConfigParserEnhanced.__init__
signature changed. Thefilename
parameter is now optional at construction time. It can be still be set via theinifilepath
property.- Parses of sections kicked off via the inner class
ConfigParserEnhancedData
such asparser.configparserenhanceddata[section]
will no longer tellparse_section
to skip callinghandler_initialize
andhandler_finalize
. The output of this call won't change, but this will affect the state ofhandler_parameters.data_shared
, and what is returned byparse_section_last_result
.
- ConfigParserEnhanced is currently alpha and has many changes occurring.
- Added
enter_handler()
method toConfigParserEnhanced
. This should be called immediately upon entry to a handler to provide logging information that can be useful when debugging. This is in the public api -- not that we encourage a subclass to modify it much but we encourage subclasses to use it in their custom handlers. - Added
exit_handler()
method toConfigParserEnhanced
This should be called just before a handler exits to provide logging and information that can be useful when debugging. This is in the public api -- not that we encourage a subclass to modify it much but we encourage subclasses to use it in their custom handlers. - Added
_launch_handler_generic
method toConfigParserEnhanced
which is a wrapper to launchinghandler_generic
. This handles launching the generic handler and updating theconfigparserenhanceddata
structure.- This was also useful because we launch the generic handler from two places in the parser.
- Moved
__version__
string to a new file,version.py
- Replaced
setup.py
withpyproject.toml
- Generated using the poetry package (
python3 -m pip install --user poetry
).
- Generated using the poetry package (
- Updated
ConfigParserEnahanced._new_handler_parameters
to create a 'new'HandlerParameters
object when called that copies in thedata_shared
anddata_internal
references from the caller but creates new entries for the other pieces. This fixed a bug in recursion ofuse <section>
entries where the handler that is called would overwrite parts ofhandler_parameters
which, as a side effect, would change the state to the caller in the recursion.- Modified the API to
_new_handler_parameters
- Added
- Modified the API to
- Fixed issue in the formatting of the
ExceptionControl
methodexception_control_event
where events are printed to the console rather than raising an exception. The message now properly prints out the call stack to the location whereexception_control_event
was called from. The warning message formatting was changed slightly as well to add the characters!!
as a prefix to all the lines in the message.
- Brought handling of a
key:value
pair where there is no separator character (:
,=
) in line with howconfigparser
handles these. If they key has a separator but no value then the value field will get an empty string, but if there is no separator then value will be set toNone
. Prior to this, ConfigParserEnhanced converted value to a string which would causeNone
to be converted to a string:"None"
.
- Removed
SetEnvironment
into its own repository. - Cleaned up
setup.py
and added new helper scripts.
0.0.1
added to help SetEnvironment have a version to pull via Pip.