OPTIONAL_PROGRAMS = {
"Google Chrome": install_google_chrome,
"HMSS": install_hmss,
"Kingdom of Cyprus": install_kingdom_of_cyprus,
...
}
[...]
class HMSoftwareInstaller:
[...]
def install(name: str, function: Callable[[], bool]) -> bool:
print(f"Installing {name}...")
if not (result := function()):
self.failure_log.append(f"Install {name}")
return result
def run_non_essentials(self) -> bool:
""" Run the installation processes. """
return all(self[self.install(*program) for program in OPTIONAL_PROGRAMS.items()])
The same applies to run_essentials()
.
The functions invoked do not use self
anyway, so they should be redefined as purefree functions.
The same applies to run_essentials()
.
Use built-ins where possible
The function upgrade_python()
does unnecessarily store state. You can rewrite it as:
def upgrade_python():
""" Install PIP3 and other useful Python hangers-on. """
return all([
install_via_apt("python3-pip"),
pip3_install("pylint"),
pip3_install("pytest")
])