hetznerctl: Add config parser for _cmd options#44
hetznerctl: Add config parser for _cmd options#44lucc wants to merge 6 commits intoaszlig:masterfrom
Conversation
aszlig
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR, only added a few nitpick comments. However what I'm not so sure whether inheriting from RawConfigParser is a good idea, since overriding methods could introduce conflicts with upstream. I'd rather prefer a dedicated function that returns something like a Dict[str, str] instead and which handles _cmd. This could also have some logic that returns an error if the configuration file contains foo and foo_cmd.
Addressing #43 (comment): So far I was trying to be as backwards-compatible as possible, supporting Python all the way down to Python 2.7.
The reason for this is that NixOps 2.0 is yet to be released and version 1.x only supports Python 2.x. However, I'm leaning towards making a version 1.x of this library (only supporting Python 3) and release fixes for the 0.x version in a different branch.
|
To address the questions:
Well, ideally the whole project would switch to using type hints, so I'd say at least Python 3.5.
Ideally, I'd lean towards Haskell's
I'm not a fan of all those |
|
Btw. these are the Python versions that are tested right now: https://headcounter.org/hydra/jobset/aszlig/hetzner#tabs-jobs |
Noted by the first review and by pycodestyle.
3625df0 to
601d4b8
Compare
This also updates the usage of the subprocess module to support python 2.7.
5f69acf to
d80a823
Compare
|
I tried to fix some things you noted. I still don't understand what kind of function you envision that returns a |
|
Sorry for the delay, I should probably try to find a way how to get notifications for my own repositories (I get notifications for like everything except the things that actually matter X-D)...
Something like this: def parse_config(file: Path) -> Dict[str, str]:
# ... do all kinds of internal stuff with RawConfigFileParser and whatnot...
return parsed_configIf I didn't miss anything, a plain old dictionary should be sufficient for representing the data. |
This wraps the config parser class from the stdlib to transparently fall back to a *_cmd option if an option is not set. The *_cmd option is expected to be a string to be passed to the python subprocess module. The return value of the that is the option value that is returned.
open questions