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

@@ -426,8 +426,8 @@ class Plugin(BaseAuthService):
assert user == user.strip()
assert user
try:
with io.StringIO(_FREERADUIS_DICT) as dct_file:
dct = pyrad.dictionary.Dictionary(dct_file)
with io.StringIO(_FREERADUIS_DICT) as file:
dct = pyrad.dictionary.Dictionary(file)
client = pyrad.client.Client(
server=self.__host,
authport=self.__port,

View File

@@ -172,8 +172,8 @@ class BaseDeviceProcess(multiprocessing.Process): # pylint: disable=too-many-in
return get_logger()
def __is_udc_configured(self) -> bool:
with open(self.__udc_state_path) as udc_state_file:
return (udc_state_file.read().strip().lower() == "configured")
with open(self.__udc_state_path) as file:
return (file.read().strip().lower() == "configured")
def __write_report(self, report: bytes) -> bool:
assert report

View File

@@ -75,13 +75,13 @@ class Drive:
# =====
def __get_param(self, param: str) -> str:
with open(os.path.join(self.__lun_path, param)) as param_file:
return param_file.read().strip()
with open(os.path.join(self.__lun_path, param)) as file:
return file.read().strip()
def __set_param(self, param: str, value: str) -> None:
try:
with open(os.path.join(self.__lun_path, param), "w") as param_file:
param_file.write(value + "\n")
with open(os.path.join(self.__lun_path, param), "w") as file:
file.write(value + "\n")
except OSError as err:
if err.errno == errno.EBUSY:
raise MsdDriveLockedError()

View File

@@ -129,12 +129,12 @@ class Plugin(BaseUserGpioDriver):
self.__set_udc_enabled(True)
def __set_udc_enabled(self, enabled: bool) -> None:
with open(self.__udc_path, "w") as udc_file:
udc_file.write(self.__udc if enabled else "\n")
with open(self.__udc_path, "w") as file:
file.write(self.__udc if enabled else "\n")
def __is_udc_enabled(self) -> bool:
with open(self.__udc_path) as udc_file:
return bool(udc_file.read().strip())
with open(self.__udc_path) as file:
return bool(file.read().strip())
def __str__(self) -> str:
return f"GPIO({self._instance_name})"