def from_gcov_match(cls, match: re.match): (coverage_str, linenum_str, source) = match.groups() if coverage_str == '-': coverage = -1 elif coverage_str in ('#####', '====='): coverage = 0 else: coverage = int(coverage_str) return cls(int(linenum_str), source, coverage)
def wrap_date_match(order: str, match: re.match, pattern: str = None) -> dict or None: """ Args: order: enums['MDY', 'DMY', 'YMD'] - order of the date match: re.match - a regex match object pattern: str - if user defined the pattern, record it here Returns: """ return { 'value': match.group(), 'groups': match.groups(), 'start': match.start(), 'end': match.end(), 'order': order, 'pattern': pattern } if match else None
def extract_groups(match: re.match): return match.groups()
def from_gcov_match(cls, linenum: int, match: re.match): (name, called_str, returned_str, blocks_str) = match.groups() return cls(name, linenum, int(called_str), int(returned_str), int(blocks_str))