def _get_blocker_status_overrides( self, testplan: TestPlanUnit ) -> "List[Tuple[str, str, str]]]": """ Look at the certification blocker status overrides and collect refined data about what overrides to apply. The result is represented as a list of tuples ``(pattern, field, value)`` where ``pattern`` is the string that describes the pattern, ``field`` is the field to which an override must be applied (but without the ``effective_`` prefix) and ``value`` is the overridden value. """ override_list = [] if testplan.certification_status_overrides is not None: class V(Visitor): def visit_FieldOverride_node(self, node: FieldOverride): blocker_status = node.value.text pattern = r"^{}$".format( testplan.qualify_id(node.pattern.text)) override_list.append( (pattern, 'certification_status', blocker_status)) V().visit(OverrideFieldList.parse( testplan.certification_status_overrides)) for tp_unit in testplan.get_nested_part(): override_list.extend(self._get_blocker_status_overrides(tp_unit)) return override_list
def parse_category_overrides(self, text): """ Parse the specified text as a list of category overrides. :param text: string of text, including newlines and comments, to parse :returns: A list of tuples (lineno_offset, category_id, pattern) where lineno_offset is the line number offset from the start of the text, category_id is the desired category identifier and pattern is the actual regular expression text (which may be invalid). :raises ValueError: if there are any issues with the override declarations """ from plainbox.impl.xparsers import Error from plainbox.impl.xparsers import FieldOverride from plainbox.impl.xparsers import OverrideFieldList from plainbox.impl.xparsers import Visitor outer_self = self class OverrideListVisitor(Visitor): def __init__(self): self.override_list = [] def visit_FieldOverride_node(self, node: FieldOverride): category_id = outer_self.qualify_id(node.value.text) regexp_pattern = r"^{}$".format( outer_self.qualify_id(node.pattern.text)) self.override_list.append( (node.lineno, category_id, regexp_pattern)) def visit_Error_node(self, node: Error): raise ValueError(node.msg) visitor = OverrideListVisitor() visitor.visit(OverrideFieldList.parse(text, 0, 0)) return visitor.override_list
def _get_category_overrides( self, testplan: TestPlanUnit) -> "List[Tuple[str, str, str]]]": """ Look at the category overrides and collect refined data about what overrides to apply. The result is represented as a list of tuples ``(pattern, field, value)`` where ``pattern`` is the string that describes the pattern, ``field`` is the field to which an override must be applied (but without the ``effective_`` prefix) and ``value`` is the overridden value. """ override_list = [] if testplan.category_overrides is None: return override_list class V(Visitor): def visit_FieldOverride_node(self, node: FieldOverride): category_id = testplan.qualify_id(node.value.text) pattern = r"^{}$".format(testplan.qualify_id( node.pattern.text)) override_list.append((pattern, 'category_id', category_id)) V().visit(OverrideFieldList.parse(testplan.category_overrides)) return override_list