Add support for YAML configuration files #141
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Applies to any provided config file ending in
.yaml
or.yml
, and searches for./.icsv2ledgerrc.yaml
and./.icsv2ledgerrc.yml
by default.Includes updates to documentation with an explanation of file path precedence and an adaptation of the existing configuration example.
Although PyYAML parses the configuration file into a dict, we immediately read it into configparser to maintain consistency in the rest of the program.
Adds an import of
chain
from theitertools
module to succinctly flatten a list of list comprehensions in the config file search-path section. I've done further refactoring of this section on my personal fork, but that's to my preferences, and likely not Pythonic, as I'm still learning what that means- my instincts are probably too DRY :pHence, I've kept this patch minimal, and only changed the lines that I needed to.
I'd have liked to support passing a list of field-indexes to the
desc
option, instead of the current solution of quoting it into a string for the existing regex-split, but found that it was always parsed in as a string ('[2, 5]'
) instead of a list ([2, 5]
), so it kept trying to iterate over the square brackets? I'm really new to Python, and am clearly missing something here. Comments welcome!