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

check if config file exists #20

Closed
torbengb opened this issue Oct 19, 2017 · 5 comments
Closed

check if config file exists #20

torbengb opened this issue Oct 19, 2017 · 5 comments

Comments

@torbengb
Copy link
Member

Also found in Scottrobertson's code:

def perform_request(path)
  raise 'Cannot find config file' unless File.exists?(config_path)
@nocalla
Copy link
Member

nocalla commented Oct 19, 2017 via email

@torbengb
Copy link
Member Author

I'm used to working with ... less experienced users, so this caught my attention when I saw it in his code. And hey, the script already works wonderfully, so what else is there to do?

I too thought about what would happen when a user (me!) grabs a new version after having made changes to the [DEFAULT] config (e.g. the same download path for all my formats). In past projects, I've had a system-default config plus a user-default config that would override the system default, plus specific configs on top of that. Parameters were read as system-then-user-then-specific so the most specific setting gets the last word.

I don't want to add too much complexity here so perhaps we could have the system-defaults as a fallback in the code, and leave the user-default in the config?

What happens if I want to to have Payee&Memo swapped on my import but you don't, for the same format? Who gets to decide the "official" format?

@nocalla
Copy link
Member

nocalla commented Oct 19, 2017

That's true. Could have a binary "active" flag for each section in the config? So "rabo Ben" could be a different section to "rabo nocalla". Maybe? Not sure about this.

The DEFAULT in config acts as fall back anyway, not sure what happens if another config file also specifies default values. Which supercedes which? Worth experimentation I think.

@torbengb
Copy link
Member Author

I suggest following your advice: walk first, run later. Our present config file works very well.

I realize that if I mess with my local copy of the config, then it's my headache to deal with the diff to a new version. If we're already asking people to edit .conf files and run .py files, we can expect that those willing to do so are also able to handle the changes they make -- or accept their loss when everything is broken and they download a fresh package.

So - would you be okay with just adding simple sanity checks like "file missing" for now? There could still be a whole lot of "missing parameter" checks in that, given that there is no fallback in the code. Without a valid config, the script can't run.

Back to the thought of having sanity checks or hardcoded fallbacks, but I think we can't make a reliable fallback for most settings (download path, delimiter, etc).

@nocalla
Copy link
Member

nocalla commented Oct 19, 2017 via email

nocalla added a commit to nocalla/bank2ynab that referenced this issue Oct 19, 2017
Print error message if config file doesn't exist. No need to do anything else, as script will just terminate anyway.
@nocalla nocalla closed this as completed Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants