use uvname for dependencies between excuses

ubuntu/rebased
Ivo De Decker 5 years ago
parent 8369d6b0e7
commit c410435859

@ -787,12 +787,11 @@ class Britney(object):
# write excuses to the output file
if not self.options.dry_run:
self.logger.info("> Writing Excuses to %s", self.options.excuses_output)
sorted_excuses = sorted(excuses.values(), key=lambda x: x.sortkey())
write_excuses(sorted_excuses, self.options.excuses_output,
write_excuses(excuses, self.options.excuses_output,
output_format="legacy-html")
if hasattr(self.options, 'excuses_yaml_output'):
self.logger.info("> Writing YAML Excuses to %s", self.options.excuses_yaml_output)
write_excuses(sorted_excuses, self.options.excuses_yaml_output,
write_excuses(excuses, self.options.excuses_yaml_output,
output_format="yaml")
self.logger.info("Update Excuses generation completed")

@ -371,7 +371,7 @@ class Excuse(object):
return VERDICT2DESC[verdict]
return "UNKNOWN: Missing description for {0} - Please file a bug against Britney".format(verdict.name)
def _render_dep_issues(self):
def _render_dep_issues(self, excuses):
if self.dep_info_rendered:
return
@ -379,13 +379,15 @@ class Excuse(object):
for d in self.all_deps:
dep = d.first_dep
info = ""
if d.valid:
info = "%s: %s <a href=\"#%s\">%s</a>" % (d.deptype, self.uvname, dep, dep)
elif not d.possible:
if not d.possible:
desc = d.first_impossible_dep
info = "Impossible %s: %s -> %s" % (d.deptype, self.uvname, desc)
else:
info = "%s: %s <a href=\"#%s\">%s</a> (not considered)" % (d.deptype, self.uvname, dep, dep)
duv = excuses[dep].uvname
if d.valid:
info = "%s: %s <a href=\"#%s\">%s</a>" % (d.deptype, self.uvname, duv, duv)
else:
info = "%s: %s <a href=\"#%s\">%s</a> (not considered)" % (d.deptype, self.uvname, duv, duv)
dep_issues[d.verdict].add("Invalidated by %s" % d.deptype.get_description())
dep_issues[d.verdict].add(info)
@ -398,11 +400,11 @@ class Excuse(object):
self.dep_info_rendered = True
def html(self):
def html(self, excuses):
"""Render the excuse in HTML"""
res = "<a id=\"%s\" name=\"%s\">%s</a> (%s to %s)\n<ul>\n" % \
(self.uvname, self.uvname, self.uvname, self.ver[0], self.ver[1])
info = self._text()
info = self._text(excuses)
for l in info:
res += "<li>%s\n" % l
res = res + "</ul>\n"
@ -417,9 +419,9 @@ class Excuse(object):
""""adding reason"""
self.reason[reason] = 1
def _text(self):
def _text(self, excuses):
"""Render the excuse in text"""
self._render_dep_issues()
self._render_dep_issues(excuses)
res = []
res.append(
"Migration status for %s (%s to %s): %s" %
@ -439,10 +441,10 @@ class Excuse(object):
res.append("" + x + "")
return res
def excusedata(self):
def excusedata(self, excuses):
"""Render the excuse in as key-value data"""
excusedata = {}
excusedata["excuses"] = self._text()
excusedata["excuses"] = self._text(excuses)
excusedata["item-name"] = self.uvname
excusedata["source"] = self.source
excusedata["migration-policy-verdict"] = self._policy_verdict.name
@ -464,20 +466,24 @@ class Excuse(object):
if self.all_deps \
or self.break_deps or self.unsat_deps:
excusedata['dependencies'] = dep_data = {}
migrate_after = sorted(set(d.first_dep for d in self.all_deps if d.valid))
blocked_by = sorted(set(d.first_dep for d in self.all_deps
if not d.valid and d.possible))
migrate_after = set(d.first_dep for d in self.all_deps if d.valid)
blocked_by = set(d.first_dep for d in self.all_deps
if not d.valid and d.possible)
break_deps = [x for x, _ in self.break_deps if
x not in migrate-after and
x not in blocked-by]
def sorted_uvnames(deps):
return sorted(excuses[d].uvname for d in deps)
if blocked_by:
dep_data['blocked-by'] = blocked_by
dep_data['blocked-by'] = sorted_uvnames(blocked_by)
if migrate_after:
dep_data['migrate-after'] = migrate_after
dep_data['migrate-after'] = sorted_uvnames(migrate_after)
if break_deps:
dep_data['unimportant-dependencies'] = sorted(break_deps)
dep_data['unimportant-dependencies'] = sorted_uvnames(break_deps)
if self.unsat_deps:
dep_data['unsatisfiable-dependencies'] = {x: sorted(self.unsat_deps[x]) for x in self.unsat_deps}
if self.needs_approval:

@ -300,16 +300,17 @@ def write_heidi_delta(filename, all_selected):
item.version, item.architecture))
def write_excuses(excuselist, dest_file, output_format="yaml"):
def write_excuses(excuses, dest_file, output_format="yaml"):
"""Write the excuses to dest_file
Writes a list of excuses in a specified output_format to the
path denoted by dest_file. The output_format can either be "yaml"
or "legacy-html".
"""
excuselist = sorted(excuses.values(), key=lambda x: x.sortkey())
if output_format == "yaml":
with open(dest_file, 'w', encoding='utf-8') as f:
edatalist = [e.excusedata() for e in excuselist]
edatalist = [e.excusedata(excuses) for e in excuselist]
excusesdata = {
'sources': edatalist,
'generated-date': datetime.utcnow(),
@ -323,7 +324,7 @@ def write_excuses(excuselist, dest_file, output_format="yaml"):
f.write("<p>Generated: " + time.strftime("%Y.%m.%d %H:%M:%S %z", time.gmtime(time.time())) + "</p>\n")
f.write("<ul>\n")
for e in excuselist:
f.write("<li>%s" % e.html())
f.write("<li>%s" % e.html(excuses))
f.write("</ul></body></html>\n")
else: # pragma: no cover
raise ValueError('Output format must be either "yaml or "legacy-html"')

Loading…
Cancel
Save