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

Move user configuration to programming language agnostic file format #20

Closed
wearymanateevedaknotstabooresisting opened this issue Mar 6, 2021 · 4 comments · Fixed by #99
Labels
good first issue Good for newcomers

Comments

@wearymanateevedaknotstabooresisting
Copy link
Contributor

wearymanateevedaknotstabooresisting commented Mar 6, 2021

Currently, the configuration is done by manipulating src/config.py which is loaded during Python module load. The user has to first navigate into the src directory and additionally manipulate a Python language code file, this is prone to errors.

However, the configuration can be moved to a file in the project root, and could be represented in a broad known file format, like JSON or INI. Subsequently, the configuration file format is easier to exchange for later usage.

Possible first approach would be a JSON which is read in during src/main.py:

{
    "country": "germany",
    "tax_fiat": "EUR",
    "tax_year": 2020,
    "tax_principle": "FIFO",
    "long_term": true,
    "long_term_duration": 365,
    "...paths": "...tbc"
}

Please provide different suggestions for the file format.

@provinzio
Copy link
Owner

I like the general idea. My thoughts on the first implementation were, that I do not have to do excessive validation, if the config stays in a python file.

I am open to moving it to a seperate file, which would definitly increase user-friendliness.

While JSON is lightweight, I'd prefer YAML or INI as they allow comments which could increase user-friendliness even more. Reducing the necessity to search for everything in the documentation. I like to stay with the standardlib of python wherever I can, which would give INI a headstart.

I think that it would be nice, if the program automatically selects default settings for the selected country, which requires some settings to be commented out by default. If we want to stay with JSON, we could do something like "tax_fiat": "default".

@wearymanateevedaknotstabooresisting
Copy link
Contributor Author

wearymanateevedaknotstabooresisting commented Mar 6, 2021

I like your proposal for using YAML because of its support of comments. Also, the default configuration value totally makes sense, I saw that you used such a default country configuration for Germany.

Might submit a new PR. Could I get your preference, where we want to parse it - leave it in config.py or move it to a config function in main.py, before starting the PR?

@provinzio
Copy link
Owner

I think it's cleaner in its own file as a Config class. Just sharing config = Config() with other files. The class should validate the input. I'll leave it to you how the class is saving the config. Eitherbas dict or flat. I am not sure what fits the purpose better.

@provinzio provinzio added the good first issue Good for newcomers label Mar 18, 2021
@scientes
Copy link
Contributor

https://docs.python.org/3/library/configparser.html

could be a perfect fit for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants