refactoring

This commit is contained in:
Maxim Devaev
2023-03-07 23:54:05 +02:00
parent 002031baf1
commit f652eca9c2
15 changed files with 49 additions and 49 deletions

View File

@@ -39,14 +39,14 @@ def _get_param_path(gadget: str, instance: int, param: str) -> str:
def _get_param(gadget: str, instance: int, param: str) -> str:
with open(_get_param_path(gadget, instance, param)) as param_file:
return param_file.read().strip()
with open(_get_param_path(gadget, instance, param)) as file:
return file.read().strip()
def _set_param(gadget: str, instance: int, param: str, value: str) -> None:
try:
with open(_get_param_path(gadget, instance, param), "w") as param_file:
param_file.write(value + "\n")
with open(_get_param_path(gadget, instance, param), "w") as file:
file.write(value + "\n")
except OSError as err:
if err.errno == errno.EBUSY:
raise SystemExit(f"Can't change {param!r} value because device is locked: {err}")