Use defaultdict to generate the mapping

This commit is contained in:
Ewoud Kohl van Wijngaarden 2012-10-11 11:44:14 +02:00 committed by josch
parent e34cde7aa5
commit 8de6168ae4

View file

@ -8,6 +8,7 @@ if len(sys.argv) != 2:
import os
from os import path
from collections import defaultdict
from subprocess import Popen, PIPE
from functools import cmp_to_key
from datetime import datetime
@ -44,19 +45,13 @@ def flatten(l):
if l: yield l.pop(0)
# read mapping between Gentoo and Debian packages
deb2gen = dict()
gen2deb = dict()
deb2gen = defaultdict(list)
gen2deb = defaultdict(list)
with open("./deb2gen_mapping.list") as f:
for line in f:
d, g = line.strip().split('\t')
if deb2gen.get(d):
deb2gen[d].append(g)
else:
deb2gen[d] = [g]
if gen2deb.get(g):
gen2deb[g].append(d)
else:
gen2deb[g] = [d]
with open("./deb_source_pkgs.list") as f:
debian_names = [p[4:].strip() for p in f]