INNER CODE UNIT · Python

read

hacan359/tonkatsu_box · tool/merge_lcov.py:17

def read(path, hits):
    current = None
    with open(path, encoding='utf-8') as handle:
        for raw in handle:
            line = raw.strip()
            if line.startswith('SF:'):
                # Normalize separators so a Windows-produced report merges with
                # a Linux-produced one.
                current = posixpath.normpath(line[3:].replace('\\', '/'))
                if (posixpath.isabs(current) or ':' in current[:3]
                        or current.startswith('..')):
                    # A path outside the repo root would silently split one
                    # file into two records — fail loudly instead.
                    raise SystemExit(f'{path}: non-repo-relative SF: {current}')
                hits.setdefault(current, collections.Counter())
            elif line.startswith('DA:') and current is not None:
                number, _, count = line[3:].partition(',')
                hits[current][int(number)] += int(count.split(',')[0])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…