# Own modules
from . import __version__
-from .common import pp, to_str, is_sequence
+from .common import pp, is_sequence
from .base_app import BaseHookError, BaseHookApp
# -------------------------------------------------------------------------
def init_filters(self):
- if 'vendor' in self.query:
- q_vendors = []
- if is_sequence(self.query['vendor']):
- for vendor in self.query['vendor']:
- v = vendor.strip().lower()
- if v and v not in q_vendors:
- q_vendors.append(v)
- else:
- v = self.query['vendor'].strip().lower()
+ self._init_filter_vendor()
+ self._init_filter_name()
+ self._init_filter_re()
+
+ # -------------------------------------------------------------------------
+ def _init_filter_vendor(self):
+
+ if 'vendor' not in self.query:
+ return
+
+ q_vendors = []
+ if is_sequence(self.query['vendor']):
+ for vendor in self.query['vendor']:
+ v = vendor.strip().lower()
if v and v not in q_vendors:
q_vendors.append(v)
- if q_vendors:
- if self.filters is None:
- self.filters = {}
- self.filters['vendor'] = q_vendors
-
- if 'name' in self.query:
- q_names = []
- if is_sequence(self.query['name']):
- for name in self.query['name']:
- v = name.strip().lower()
- if v and v not in q_names:
- q_names.append(v)
- else:
- v = self.query['name'].strip().lower()
+ else:
+ v = self.query['vendor'].strip().lower()
+ if v and v not in q_vendors:
+ q_vendors.append(v)
+ if q_vendors:
+ if self.filters is None:
+ self.filters = {}
+ self.filters['vendor'] = q_vendors
+
+ # -------------------------------------------------------------------------
+ def _init_filter_name(self):
+
+ if 'name' not in self.query:
+ return
+
+ q_names = []
+ if is_sequence(self.query['name']):
+ for name in self.query['name']:
+ v = name.strip().lower()
if v and v not in q_names:
q_names.append(v)
- if q_names:
- if self.filters is None:
- self.filters = {}
- self.filters['name'] = q_names
-
- if 're' in self.query:
- q_re = []
- if is_sequence(self.query['re']):
- for regex in self.query['re']:
- v = regex.strip()
- if v:
- q_re.append(v)
- else:
- v = self.query['re'].strip()
+ else:
+ v = self.query['name'].strip().lower()
+ if v and v not in q_names:
+ q_names.append(v)
+ if q_names:
+ if self.filters is None:
+ self.filters = {}
+ self.filters['name'] = q_names
+
+ # -------------------------------------------------------------------------
+ def _init_filter_re(self):
+
+ if 're' not in self.query:
+ return
+
+ q_re = []
+ if is_sequence(self.query['re']):
+ for regex in self.query['re']:
+ v = regex.strip()
if v:
q_re.append(v)
- if q_re:
- if self.filters is None:
- self.filters = {}
- for regex in q_re:
- regex_compiled = None
- try:
- regex_compiled = re.compile(regex, re.IGNORECASE)
- except Exception as e:
- LOG.error("{c}: Invalid regular expression {r!r}: {e}".format(
- c=e.__class__.__name__, r=regex, e=e))
- else:
- if 're' not in self.filters:
- self.filters['re'] = []
- if regex_compiled not in self.filters['re']:
- self.filters['re'].append(regex_compiled)
+ else:
+ v = self.query['re'].strip()
+ if v:
+ q_re.append(v)
+ if q_re:
+ if self.filters is None:
+ self.filters = {}
+ for regex in q_re:
+ regex_compiled = None
+ try:
+ regex_compiled = re.compile(regex, re.IGNORECASE)
+ except Exception as e:
+ LOG.error("{c}: Invalid regular expression {r!r}: {e}".format(
+ c=e.__class__.__name__, r=regex, e=e))
+ else:
+ if 're' not in self.filters:
+ self.filters['re'] = []
+ if regex_compiled not in self.filters['re']:
+ self.filters['re'].append(regex_compiled)
# -------------------------------------------------------------------------
def run(self):
self.print_out(' <th rowspan="2" class="l h confluenceTh">Name</th>')
self.print_out(' <th rowspan="2" class="l h confluenceTh">Vollständiger Name</th>')
self.print_out(' <th rowspan="2" class="h confluenceTh">Repository</th>')
- self.print_out(' <th rowspan="2" class="h confluenceTh">Homepage bei Puppet Forge</th>')
+ self.print_out(
+ ' <th rowspan="2" class="h confluenceTh">Homepage bei Puppet Forge</th>')
self.print_out(' <th colspan="4" class="h confluenceTh">Version</th>')
self.print_out(' <th rowspan="2" class="h confluenceTh">Letzter Check</th>')
self.print_out(' </tr><tr>')