repos: Rewrite missing_rating in terms of BuildReporter
This commit is contained in:
parent
a7df65c0e4
commit
e2f1051f7d
@ -576,32 +576,35 @@ class BuildReporter:
|
||||
return to('\n'.join(result)) if to else '\n'.join(result)
|
||||
|
||||
|
||||
def missing_rating(from_repo, to_repo):
|
||||
def missing_rating(build_reporter, ignore=None):
|
||||
result = collections.defaultdict(set)
|
||||
reporter = BuildReporter(from_repo, to_repo)
|
||||
for name in from_repo.sources:
|
||||
if name in to_repo.sources or b'gost' in name:
|
||||
continue
|
||||
ignore = re.compile(ignore).search if ignore else lambda x: False
|
||||
|
||||
sources = (s for s in build_reporter.from_repo.sources
|
||||
if s not in build_reporter.to_repo.sources
|
||||
and b'gost' not in s
|
||||
and not s.startswith(b'kernel-')
|
||||
and not ignore(s))
|
||||
for name in sources:
|
||||
try:
|
||||
rbr = reporter.recursive_closure([name])
|
||||
rbr = build_reporter.recursive_closure([name])
|
||||
except Exception:
|
||||
LOG.error("Failed to build recursive build report "
|
||||
"for %s", name.decode(), exc_info=True)
|
||||
else:
|
||||
for other_name in rbr:
|
||||
if other_name != name:
|
||||
if other_name != name and not ignore(name):
|
||||
result[other_name].add(name)
|
||||
return sorted(result.items(), key=lambda x: (len(x[1]), x[0]))
|
||||
return dict(result)
|
||||
|
||||
|
||||
def missing_rating_report(from_repo, to_repo):
|
||||
rr = list(reversed(missing_rating(from_repo, to_repo)))
|
||||
def format_missing_rating(rating, to=None):
|
||||
rr = sorted(rating.items(), key=lambda x: (-len(x[1]), x[0]))
|
||||
result = []
|
||||
for name, where in rr:
|
||||
present = '+' if name in to_repo.sources else ''
|
||||
result.append(f"{name.decode()} {present}: {len(where)}")
|
||||
result.append(" " + b' '.join(where).decode())
|
||||
return '\n'.join(result)
|
||||
result.append(f"{name.decode()}: {len(where)}")
|
||||
result.append(" " + b' '.join(sorted(where)).decode())
|
||||
return to('\n'.join(result)) if to else '\n'.join(result)
|
||||
|
||||
|
||||
def recursive_build_report(from_repo, to_repo, *source_names,
|
||||
|
Loading…
Reference in New Issue
Block a user