From 3ba5de5c01aec3b2a3cd07b9f875bac3c7b8fe88 Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Mon, 27 Aug 2018 14:50:49 +0200 Subject: [PATCH] Creating HTML table --- lib/webhooks/__init__.py | 2 +- lib/webhooks/show_modules.py | 61 ++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/lib/webhooks/__init__.py b/lib/webhooks/__init__.py index 8c0b943..79baaa9 100644 --- a/lib/webhooks/__init__.py +++ b/lib/webhooks/__init__.py @@ -1,6 +1,6 @@ #!/bin/env python3 # -*- coding: utf-8 -*- -__version__ = '0.10.5' +__version__ = '0.10.6' # vim: ts=4 et list diff --git a/lib/webhooks/show_modules.py b/lib/webhooks/show_modules.py index f093e28..e8d8cfa 100644 --- a/lib/webhooks/show_modules.py +++ b/lib/webhooks/show_modules.py @@ -150,6 +150,8 @@ class ShowModulesApp(BaseHookApp): if self.output_type == 'json': self.output_modules_json(module_infos) + elif self.output_type == 'html': + self.output_modules_html(module_infos) # ------------------------------------------------------------------------- def output_modules_json(self, module_infos): @@ -165,6 +167,63 @@ class ShowModulesApp(BaseHookApp): self.print_out(json.dumps(output_list, indent=indent, sort_keys=True)) + # ------------------------------------------------------------------------- + def output_modules_html(self, module_infos): + + self.print_out('') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + self.print_out(' ') + + nr_modules = 0 + + for module_info in module_infos: + nr_modules += 1 + output_data = self.get_output_data(module_info) + if not output_data['forge_version']: + output_data['forge_version'] = '~' + if not output_data['forge_homepage_url']: + output_data['forge_homepage_url'] = '~' + if not output_data['repo']: + output_data['repo'] = '~' + tpl = ' \n' + tpl += ' \n' + tpl += ' \n' + tpl += ' \n' + tpl += ' \n' + tpl += ' \n' + tpl += ' \n' + tpl += ' \n' + tpl += ' \n' + tpl += ' \n' + tpl += ' ' + if self.verbose > 2: + LOG.debug("Row template:\n{}".format(tpl)) + self.print_out(tpl.format(**output_data)) + + self.print_out(" ") + self.print_out("
NameVollständiger NameRepositoryHomepage bei Puppet ForgeVersionLetzter Check
Puppet ForgeDevelopmentTestProduction
{name}{full_name}{repo}{forge_homepage_url}{forge_version}{version_development}{version_test}{version_production}{date_checked}
") + + plural_e = 'e' + if nr_modules == 1: + plural_e = '' + msg = "
Insgesamt {nr} Modul{e} gefunden.".format(nr=nr_modules, e=plural_e) + self.print_out(msg) + # ------------------------------------------------------------------------- def get_output_data(self, module_info): @@ -188,6 +247,8 @@ class ShowModulesApp(BaseHookApp): 'version_test': module_info.local_version_output('test'), 'version_production': module_info.local_version_output('production'), } + if self.verbose > 2: + LOG.debug("Output data:\n{}".format(pp(output_data))) return output_data # ------------------------------------------------------------------------- -- 2.39.5