[liveimage-diff] Sort output

This commit is contained in:
Colin Walters 2010-04-08 23:18:18 -04:00
parent 0303dc173a
commit 2e7ab7cb7a

View File

@ -65,16 +65,24 @@ def main():
read_rpmdata(original_rpmdata, original_rpms) read_rpmdata(original_rpmdata, original_rpms)
read_rpmdata(new_rpmdata, new_rpms) read_rpmdata(new_rpmdata, new_rpms)
for rpm in original_rpms: original_set = set(original_rpms)
if rpm in new_rpms: new_set = set(new_rpms)
sizedelta = new_rpms[rpm] - original_rpms[rpm] intersection = original_set.intersection(new_set)
print '= %s: %d' % (rpm, sizedelta) intersection_deltas = {}
else: for rpm in intersection:
print "- %s %d" % (rpm, original_rpms[rpm]) delta = new_rpms[rpm] - original_rpms[rpm]
for rpm in new_rpms: if delta != 0:
if rpm in original_rpms: intersection_deltas[rpm] = delta
continue
print "+ %s %d" % (rpm, new_rpms[rpm]) added_set = new_set - original_set
removed_set = original_set - new_set
for rpm in sorted(added_set, lambda a,b: cmp(new_rpms[a], new_rpms[b])):
print '+ %s %d' % (rpm, new_rpms[rpm])
for rpm in sorted(removed_set, lambda a,b: cmp(original_rpms[a], original_rpms[b])):
print '- %s %d' % (rpm, original_rpms[rpm])
for rpm in sorted(intersection_deltas, lambda a,b: cmp(intersection_deltas[a], intersection_deltas[b])):
print '= %s %d' % (rpm, intersection_deltas[rpm])
sys.exit(0) sys.exit(0)