Skip to content

Commit

Permalink
Addon Manager: Linter cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
chennes committed Jul 13, 2024
1 parent d7d1a03 commit 9a51e2c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/Mod/AddonManager/addonmanager_workers_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,9 @@ def process_package_xml(self, repo: Addon, data: QtCore.QByteArray):
def _ensure_string(self, arbitrary_data, addon_name, file_name) -> str:
if isinstance(arbitrary_data, str):
return arbitrary_data
elif isinstance(arbitrary_data, QtCore.QByteArray):
if isinstance(arbitrary_data, QtCore.QByteArray):
return self._decode_data(arbitrary_data.data(), addon_name, file_name)
else:
return self._decode_data(arbitrary_data, addon_name, file_name)
return self._decode_data(arbitrary_data, addon_name, file_name)

def _decode_data(self, byte_data, addon_name, file_name) -> str:
"""UTF-8 decode data, and print an error message if that fails"""
Expand Down
17 changes: 8 additions & 9 deletions src/Mod/AddonManager/addonmanager_workers_startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# ***************************************************************************

""" Worker thread classes for Addon Manager startup """
import datetime
import hashlib
import json
import os
Expand All @@ -45,7 +44,6 @@
import NetworkManager
from addonmanager_git import initialize_git, GitFailed
from addonmanager_metadata import MetadataReader, get_branch_from_metadata
import addonmanager_freecad_interface as fci

translate = FreeCAD.Qt.translate

Expand Down Expand Up @@ -455,7 +453,7 @@ def run(self):
if os.path.isfile(repo_metadata_cache_path):
try:
repo.load_metadata_file(repo_metadata_cache_path)
except Exception as e:
except RuntimeError as e:
FreeCAD.Console.PrintLog(f"Failed loading {repo_metadata_cache_path}\n")
FreeCAD.Console.PrintLog(str(e) + "\n")
self.addon_repo.emit(repo)
Expand Down Expand Up @@ -578,7 +576,7 @@ def check_workbench(self, wb):
with wb.git_lock:
try:
status = self.git_manager.status(clonedir)
if "(no branch)" in self.git_manager.status(clonedir):
if "(no branch)" in status:
# By definition, in a detached-head state we cannot
# update, so don't even bother checking.
wb.set_status(Addon.Status.NO_UPDATE_AVAILABLE)
Expand Down Expand Up @@ -619,7 +617,7 @@ def _branch_name_changed(self, package: Addon) -> bool:
remote_default_branch = get_branch_from_metadata(package.metadata)
if installed_default_branch != remote_default_branch:
return True
except Exception:
except RuntimeError:
return False
return False

Expand Down Expand Up @@ -664,7 +662,7 @@ def check_package(self, package: Addon) -> None:
package.set_status(Addon.Status.UPDATE_AVAILABLE)
else:
package.set_status(Addon.Status.NO_UPDATE_AVAILABLE)
except Exception:
except RuntimeError:
FreeCAD.Console.PrintWarning(
translate(
"AddonsInstaller",
Expand All @@ -687,7 +685,7 @@ def check_macro(self, macro_wrapper: Addon) -> None:
mac = mac.replace("+", "%2B")
url = "https://wiki.freecad.org/Macro_" + mac
macro_wrapper.macro.fill_details_from_wiki(url)
except Exception:
except RuntimeError:
FreeCAD.Console.PrintWarning(
translate(
"AddonsInstaller",
Expand Down Expand Up @@ -936,7 +934,8 @@ def run(self):
FreeCAD.Console.PrintError(
translate(
"AddonsInstaller",
"Failed to get Addon statistics from {} -- only sorting alphabetically will be accurate\n",
"Failed to get Addon statistics from {} -- only sorting alphabetically will"
" be accurate\n",
).format(self.url)
)
return
Expand Down Expand Up @@ -995,5 +994,5 @@ def run(self):
self.update_addon_score.emit(addon)
except (ValueError, OverflowError):
FreeCAD.Console.PrintLog(
f"Failed to convert score value '{score}' to an integer for addon {addon.name}"
f"Failed to convert score value '{score}' to an integer for {addon.name}"
)

0 comments on commit 9a51e2c

Please sign in to comment.