Skip to content

Commit 37531bb

Browse files
committed
fixes / optimisations
1 parent 913f0f3 commit 37531bb

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

mktxp/flow/router_connection.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,11 @@ def __init__(self, router_name, config_entry):
6868
with open(self.config_entry.credentials_file, 'r') as file:
6969
try:
7070
credentials = yaml.safe_load(file)
71-
if isinstance(credentials, str):
72-
raise TypeError(credentials)
73-
except (TypeError, yaml.YAMLError) as e:
74-
print('Error parsing credentials file - check that it is valid yaml')
75-
exit(1)
76-
71+
if not isinstance(credentials, dict):
72+
raise yaml.YAMLError("Credentials file is not a valid key-value map.")
73+
except yaml.YAMLError as e:
74+
print(f"Error parsing credentials file: {e}\nCheck that it is valid YAML (e.g., 'username: user').")
75+
exit(1)
7776
username = credentials.get('username', username)
7877
password = credentials.get('password', password)
7978

0 commit comments

Comments
 (0)