diff options
author | Håkon Solbjørg <hlsolbjorg@gmail.com> | 2019-04-02 00:58:09 +0200 |
---|---|---|
committer | Håkon Solbjørg <hlsolbjorg@gmail.com> | 2019-04-02 19:56:20 +0200 |
commit | 1ceefd7d700caf18f2390b94aa81d9f0207a4d85 (patch) | |
tree | 8af07d61e62e27ad0ee73efa3adc84e7bd874e3c /gondul.py | |
parent | aacc12dc9ab445e020444a5bd32b51f1fb62ddb8 (diff) |
chore: Refactor to get switches from gondul before executing labler ♻️
Diffstat (limited to 'gondul.py')
-rw-r--r-- | gondul.py | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -61,6 +61,16 @@ def _sort_switches(switches): return sorted(switches, key=lambda x: (int(x[1:].split("-")[0]), x.split("-")[1])) -def fetch_gondul_switches(match="^e(.*)"): - # credentials = _generate_credentials() - return _sort_switches(_match_switches(_do_switches_request())) +def fetch_gondul_switches(api=None, endpoint=None, username=None, password=None, match="^e(.*)"): + # Use provided arg instead of environment variable if defined. + _api = api if api is not None else GONDUL_API + _endpoint = endpoint if endpoint is not None else GONDUL_SWITCHES_ENDPOINT + _username = username if username is not None else GONDUL_USERNAME + _password = password if password is not None else GONDUL_PASSWORD + credentials = _generate_credentials(_username, _password) + + return _sort_switches( + _match_switches( + _do_switches_request( + api=_api, endpoint=_endpoint, credentials=credentials), + match=match)) |