mirror of
https://git.zavage.net/Zavage-Software/app_skellington.git
synced 2025-01-02 10:59:21 -07:00
build: cleaning many of the flake8 errors
This commit is contained in:
parent
cb07dd6bb2
commit
7e02553c18
@ -28,7 +28,7 @@ def does_file_exist(filepath):
|
||||
instant in execution.
|
||||
"""
|
||||
try:
|
||||
fp = open(filepath, "r")
|
||||
open(filepath, "r")
|
||||
return True
|
||||
except FileNotFoundError as ex:
|
||||
return False
|
||||
|
@ -102,6 +102,7 @@ class ApplicationContainer:
|
||||
except KeyError as ex:
|
||||
msg = "failed to inject service: {}".format(service_name)
|
||||
_bootstrap_logger.critical(msg)
|
||||
_bootstrap_logger.debug(ex)
|
||||
raise ServiceNotFound
|
||||
|
||||
def __setitem__(self, service_name, value):
|
||||
@ -129,7 +130,7 @@ class ApplicationContainer:
|
||||
dependencies.append(self[dep_name])
|
||||
return model_constructor(*dependencies)
|
||||
|
||||
def _get_config_filepath(self, app_name, app_author, config_filename="config.ini"):
|
||||
def _get_config_filepath(self, app_name, app_author, config_filename="config.ini") -> str:
|
||||
"""
|
||||
Attempt to find config.ini in the user's config directory.
|
||||
|
||||
@ -141,7 +142,7 @@ class ApplicationContainer:
|
||||
_bootstrap_logger.info("default config filepath calculated to be: %s", filepath)
|
||||
return filepath
|
||||
|
||||
def _get_configspec_filepath(self, configspec_filename="config.spec"):
|
||||
def _get_configspec_filepath(self, configspec_filename: str = "config.spec") -> str:
|
||||
"""
|
||||
Attempt to find config.spec inside the installed package directory.
|
||||
"""
|
||||
@ -162,7 +163,7 @@ class ApplicationContainer:
|
||||
|
||||
return functools.partial(self._construct_model, constructor, *cls_dependencies)
|
||||
|
||||
def load_command(self):
|
||||
def load_command(self) -> bool:
|
||||
args, unk, success = self.cli.parse()
|
||||
if not success:
|
||||
return False
|
||||
@ -180,13 +181,13 @@ class ApplicationContainer:
|
||||
print("Failure: No command specified.")
|
||||
|
||||
def interactive_shell(self):
|
||||
pass
|
||||
raise NotImplementedError()
|
||||
|
||||
def invoke_from_cli(self):
|
||||
self.invoke_command()
|
||||
|
||||
def usage(self):
|
||||
pass
|
||||
raise NotImplementedError()
|
||||
# Applications need a default usage
|
||||
|
||||
|
||||
|
@ -95,14 +95,15 @@ class Config:
|
||||
_bootstrap_logger.critical("cfg - Failed to find config.spec: file not found (%s)", filepath)
|
||||
raise OSError("Failed to read provided config.spec file")
|
||||
|
||||
self.load_config()
|
||||
# TODO(MG) initial code was present but unreachable. is an error in coding.
|
||||
# self.load_config()
|
||||
|
||||
def __contains__(self, key):
|
||||
try:
|
||||
has_item = key in self._config_obj
|
||||
return has_item
|
||||
except KeyError as ex:
|
||||
pass
|
||||
_bootstrap_logger.error("failed to __containers__ on key (%s): %s", key, ex)
|
||||
|
||||
def __delitem__(self, key):
|
||||
"""
|
||||
@ -112,7 +113,7 @@ class Config:
|
||||
try:
|
||||
del self[key]
|
||||
except KeyError as ex:
|
||||
pass
|
||||
_bootstrap_logger.error("failed to __delitem__ on key (%s): %s", key, ex)
|
||||
|
||||
def __getitem__(self, key):
|
||||
"""
|
||||
@ -126,6 +127,7 @@ class Config:
|
||||
# return self._config_obj[key].dict()
|
||||
return self._config_obj[key]
|
||||
except KeyError as ex:
|
||||
_bootstrap_logger.error("failed to __getitem__ on key (%s): %s", key, ex)
|
||||
raise
|
||||
|
||||
def __setitem__(self, key, value):
|
||||
@ -146,9 +148,16 @@ class Config:
|
||||
v = self.__getitem__(key)
|
||||
return v
|
||||
except KeyError as ex:
|
||||
_bootstrap_logger.error("failed to retrieve config key (%s): %s", key, ex)
|
||||
return default
|
||||
|
||||
def load_config(self, configspec_filepath=None, configini_filepath=None):
|
||||
def load_config(self, configspec_filepath=None, configini_filepath=None) -> bool:
|
||||
"""
|
||||
Loads config from file, validating against configspec.
|
||||
|
||||
Returns:
|
||||
bool: success status of command and validation.
|
||||
"""
|
||||
# Set new arguments if were passed in:
|
||||
if configspec_filepath is not None:
|
||||
self.configspec_filepath = configspec_filepath
|
||||
@ -195,7 +204,7 @@ class Config:
|
||||
_bootstrap_logger.error(msg)
|
||||
return False
|
||||
except Exception as ex:
|
||||
print(ex)
|
||||
_bootstrap_logger.error(ex)
|
||||
|
||||
def _validate_config_against_spec(self):
|
||||
config_spec = self.configspec_filepath
|
||||
@ -229,6 +238,7 @@ class Config:
|
||||
return False
|
||||
except ValueError as ex:
|
||||
_bootstrap_logger.error("cfg - Failed while validating config against spec. ")
|
||||
_bootstrap_logger.debug(ex)
|
||||
return False
|
||||
|
||||
def _validate_parse_errors(self, test_results):
|
||||
|
@ -66,7 +66,7 @@ class CommandTree:
|
||||
self._single_command = None
|
||||
|
||||
def print_tree(self):
|
||||
raise NotImplemented
|
||||
raise NotImplementedError()
|
||||
|
||||
def add_argument(self, *args, **kwargs):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user