Some minor style improvements

This commit is contained in:
Alessandro
2020-02-29 21:43:40 +01:00
parent bcd24cc035
commit ab32fbbf98
4 changed files with 14 additions and 26 deletions

View File

@@ -38,7 +38,4 @@ class Settings:
"""Return the corresponding setting.
Return None if there is no such setting yet."""
try:
return self._dct[attr]
except Exception:
return None
return self._dct.get(attr, None)

View File

@@ -30,12 +30,12 @@ class UniqueMessageBox(QMessageBox):
"""Overrides QMessageBox.exec. Call the parent method if there are no
other instances executing exec; also set the current font.
Otherwise return None,"""
if UniqueMessageBox._open_message:
if self.__class__._open_message:
return None
self.setFont(self._font)
UniqueMessageBox._open_message = True
self.__class__._open_message = True
answer = super().exec()
UniqueMessageBox._open_message = False
self.__class__._open_message = False
return answer
def show(self):

View File

@@ -63,14 +63,9 @@ def _download_versions_file():
}
}
"""
try:
version_dict = json.load(
BytesIO(download_file(Constants.VERSION_LINK))
)[get_os()]
except Exception:
return None
else:
return version_dict
return json.load(
BytesIO(download_file(Constants.VERSION_LINK))
).get(get_os(), None)
class VersionController:
@@ -80,7 +75,6 @@ class VersionController:
def __init__(self, dct=None):
"""Initialize the dictionary"""
super().__init__()
self._dct = dct
def __getattr__(self, attr):
@@ -89,16 +83,14 @@ class VersionController:
if self._dct is None:
if not self.update():
return None
try:
dct_element = self._dct[attr]
except Exception("ERROR: Invalid attribute!"):
dct_element = self._dct.get(attr, None)
if dct_element is None:
return None
if isinstance(dct_element, dict):
setattr(self, attr, type(self)(dct_element))
else:
if isinstance(dct_element, dict):
setattr(self, attr, type(self)(dct_element))
else:
setattr(self, attr, dct_element)
return getattr(self, attr)
setattr(self, attr, dct_element)
return getattr(self, attr)
def update(self):
"""Reset the dictionary to the correspondig json file containing

View File

@@ -37,10 +37,9 @@ def _download_multiline_file_as_list(url=Database.LINK_REF):
The downloaded file is a csv file with columns (last version == last line):
data.zip_SHA256 | db.csv_SHA256 | Version | Creation_date"""
try:
f = download_file(url, encoding="UTF-8").splitlines()[-1].split(Database.DELIMITER)
return download_file(url, encoding="UTF-8").splitlines()[-1].split(Database.DELIMITER)
except Exception:
return None
return f
def get_folder_hash_code():