From: Frank Brehm Date: Mon, 27 Aug 2018 12:50:49 +0000 (+0200) Subject: Creating HTML table X-Git-Tag: 0.10.7^2~1 X-Git-Url: https://git.uhu-banane.org/?a=commitdiff_plain;h=3ba5de5c01aec3b2a3cd07b9f875bac3c7b8fe88;p=pixelpark%2Fpuppetmaster-webhooks.git Creating HTML table --- 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 # -------------------------------------------------------------------------