import io
import cgi
import textwrap
+import copy
from email.message import EmailMessage
pass
+# =============================================================================
+class UncriticalHookError(BaseHookError):
+ """
+ Class for uncritical errors, which could and should be caught.
+ """
# =============================================================================
class BaseHookApp(BaseObject):
'errors': 'surrogateescape',
}
+ main_branches = ('development', 'test', 'production')
+
# -------------------------------------------------------------------------
def __init__(self, appname=None, base_dir=None, verbose=0, version=__version__):
"""Constructor."""
res['html_title'] = self.html_title
res['no_error_mail'] = self.no_error_mail
res['open_args'] = self.open_args
+ res['main_branches'] = copy.copy(self.main_branches)
return res
LOG.debug("Searching for {!r} ...".format(self.cachefile))
if not os.path.exists(self.cachefile):
- raise ShowModulesUncriticalError(
+ raise UncriticalHookError(
"Cache file {!r} not found.".format(self.cachefile))
if not os.access(self.cachefile, os.R_OK):
- raise ShowModulesUncriticalError(
+ raise UncriticalHookError(
"Cache file {!r} not readable.".format(self.cachefile))
modules = ModuleInfoDict(
if self.should_display(module_info):
modules.append(module_info)
except yaml.YAMLError as e:
- raise ShowModulesUncriticalError(
+ raise UncriticalHookError(
"Could not evaluate content of {f!r}: {e}".format(f=self.cachefile, e=e))
if self.verbose > 3:
LOG.debug("Content of {f!r}:\n{c}".format(f=self.cachefile, c=pp(modules.as_list())))
return modules
+ # -------------------------------------------------------------------------
+ def should_display(self, module_info):
+
+ return True
# =============================================================================
from .common import pp, is_sequence
-from .base_app import BaseHookError, BaseHookApp
+from .base_app import BaseHookError, BaseHookApp, UncriticalHookError
from .module_info import ModuleInfo
pass
# =============================================================================
-class ShowModulesUncriticalError(ShowModulesError):
+class ShowModulesUncriticalError(ShowModulesError, UncriticalHookError):
pass
Class for the application objects.
"""
- main_branches = ('development', 'test', 'production')
-
# -------------------------------------------------------------------------
def __init__(self, output_type='json', appname=None, verbose=0, version=__version__):
"""Constructor."""
res = super(ShowModulesApp, self).as_dict(short=short)
- res['main_branches'] = copy.copy(self.main_branches)
-
return res
# -------------------------------------------------------------------------
module_infos = []
try:
module_infos = self.read_cache_file()
- except ShowModulesUncriticalError as e:
+ except UncriticalHookError as e:
LOG.error(str(e))
else:
self.output_modules(module_infos)