diff options
author | Devaev Maxim <[email protected]> | 2020-05-25 01:49:39 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-05-25 01:49:39 +0300 |
commit | d5dca5a8b4eadd988505a6d84e2807cbea6c6d11 (patch) | |
tree | 6d8186cd8ec58057cfff020814de4c0eb1ed6e0f /kvmd | |
parent | 499cbb0cc57346708525dd1d0059e65a74598980 (diff) |
refactoring
Diffstat (limited to 'kvmd')
-rw-r--r-- | kvmd/apps/ipmi/auth.py | 16 | ||||
-rw-r--r-- | kvmd/apps/vnc/vncauth.py | 14 | ||||
-rw-r--r-- | kvmd/keyboard/keysym.py | 4 |
3 files changed, 17 insertions, 17 deletions
diff --git a/kvmd/apps/ipmi/auth.py b/kvmd/apps/ipmi/auth.py index 7d17edc3..b9e4a644 100644 --- a/kvmd/apps/ipmi/auth.py +++ b/kvmd/apps/ipmi/auth.py @@ -28,8 +28,8 @@ from typing import Dict # ===== class IpmiPasswdError(Exception): - def __init__(self, path: str, number: int, msg: str) -> None: - super().__init__(f"Syntax error at {path}:{number}: {msg}") + def __init__(self, path: str, lineno: int, msg: str) -> None: + super().__init__(f"Syntax error at {path}:{lineno}: {msg}") @dataclasses.dataclass(frozen=True) @@ -57,30 +57,30 @@ class IpmiAuthManager: def __parse_passwd_file(self, lines: List[str]) -> Dict[str, IpmiUserCredentials]: credentials: Dict[str, IpmiUserCredentials] = {} - for (number, line) in enumerate(lines): + for (lineno, line) in enumerate(lines): if len(line.strip()) == 0 or line.lstrip().startswith("#"): continue if " -> " not in line: - raise IpmiPasswdError(self.__path, number, "Missing ' -> ' operator") + raise IpmiPasswdError(self.__path, lineno, "Missing ' -> ' operator") (left, right) = map(str.lstrip, line.split(" -> ", 1)) for (name, pair) in [("left", left), ("right", right)]: if ":" not in pair: - raise IpmiPasswdError(self.__path, number, f"Missing ':' operator in {name} credentials") + raise IpmiPasswdError(self.__path, lineno, f"Missing ':' operator in {name} credentials") (ipmi_user, ipmi_passwd) = left.split(":") ipmi_user = ipmi_user.strip() if len(ipmi_user) == 0: - raise IpmiPasswdError(self.__path, number, "Empty IPMI user (left)") + raise IpmiPasswdError(self.__path, lineno, "Empty IPMI user (left)") (kvmd_user, kvmd_passwd) = right.split(":") kvmd_user = kvmd_user.strip() if len(kvmd_user) == 0: - raise IpmiPasswdError(self.__path, number, "Empty KVMD user (left)") + raise IpmiPasswdError(self.__path, lineno, "Empty KVMD user (left)") if ipmi_user in credentials: - raise IpmiPasswdError(self.__path, number, f"Found duplicating user {ipmi_user!r} (left)") + raise IpmiPasswdError(self.__path, lineno, f"Found duplicating user {ipmi_user!r} (left)") credentials[ipmi_user] = IpmiUserCredentials( ipmi_user=ipmi_user, diff --git a/kvmd/apps/vnc/vncauth.py b/kvmd/apps/vnc/vncauth.py index 0689b9ca..06420ee0 100644 --- a/kvmd/apps/vnc/vncauth.py +++ b/kvmd/apps/vnc/vncauth.py @@ -32,8 +32,8 @@ from ...logging import get_logger # ===== class VncAuthError(Exception): - def __init__(self, path: str, number: int, msg: str) -> None: - super().__init__(f"Syntax error at {path}:{number}: {msg}") + def __init__(self, path: str, lineno: int, msg: str) -> None: + super().__init__(f"Syntax error at {path}:{lineno}: {msg}") # ===== @@ -68,24 +68,24 @@ class VncAuthManager: lines = (await vc_file.read()).split("\n") credentials: Dict[str, VncAuthKvmdCredentials] = {} - for (number, line) in enumerate(lines): + for (lineno, line) in enumerate(lines): if len(line.strip()) == 0 or line.lstrip().startswith("#"): continue if " -> " not in line: - raise VncAuthError(self.__path, number, "Missing ' -> ' operator") + raise VncAuthError(self.__path, lineno, "Missing ' -> ' operator") (vnc_passwd, kvmd_userpass) = map(str.lstrip, line.split(" -> ", 1)) if ":" not in kvmd_userpass: - raise VncAuthError(self.__path, number, "Missing ':' operator in KVMD credentials (right part)") + raise VncAuthError(self.__path, lineno, "Missing ':' operator in KVMD credentials (right part)") (kvmd_user, kvmd_passwd) = kvmd_userpass.split(":") kvmd_user = kvmd_user.strip() if len(kvmd_user) == 0: - raise VncAuthError(self.__path, number, "Empty KVMD user (right part)") + raise VncAuthError(self.__path, lineno, "Empty KVMD user (right part)") if vnc_passwd in credentials: - raise VncAuthError(self.__path, number, "Duplicating VNC password (left part)") + raise VncAuthError(self.__path, lineno, "Duplicating VNC password (left part)") credentials[vnc_passwd] = VncAuthKvmdCredentials(kvmd_user, kvmd_passwd) return credentials diff --git a/kvmd/keyboard/keysym.py b/kvmd/keyboard/keysym.py index 3749f7da..89919e5c 100644 --- a/kvmd/keyboard/keysym.py +++ b/kvmd/keyboard/keysym.py @@ -107,7 +107,7 @@ def _read_keyboard_layout(path: str) -> Dict[int, At1Key]: # Keysym to evdev (a lines = list(map(str.strip, layout_file.read().split("\n"))) layout: Dict[int, At1Key] = {} - for (number, line) in enumerate(lines): + for (lineno, line) in enumerate(lines): if len(line) == 0 or line.startswith(("#", "map ", "include ")): continue @@ -122,5 +122,5 @@ def _read_keyboard_layout(path: str) -> Dict[int, At1Key]: # Keysym to evdev (a ctrl=("ctrl" in parts[2:]), ) except ValueError as err: - logger.error("Syntax error at %s:%d: %s", path, number, err) + logger.error("Syntax error at %s:%d: %s", path, lineno, err) return layout |