Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for YAML configuration files #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

antler5
Copy link

@antler5 antler5 commented Aug 4, 2021

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 the itertools 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 :p
Hence, 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!

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 the `itertools` 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 :p
Hence, 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!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant