Use defaultdict to generate the mapping
This commit is contained in:
parent
e34cde7aa5
commit
8de6168ae4
1 changed files with 5 additions and 10 deletions
|
@ -8,6 +8,7 @@ if len(sys.argv) != 2:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from os import path
|
from os import path
|
||||||
|
from collections import defaultdict
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
from functools import cmp_to_key
|
from functools import cmp_to_key
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -44,19 +45,13 @@ def flatten(l):
|
||||||
if l: yield l.pop(0)
|
if l: yield l.pop(0)
|
||||||
|
|
||||||
# read mapping between Gentoo and Debian packages
|
# read mapping between Gentoo and Debian packages
|
||||||
deb2gen = dict()
|
deb2gen = defaultdict(list)
|
||||||
gen2deb = dict()
|
gen2deb = defaultdict(list)
|
||||||
with open("./deb2gen_mapping.list") as f:
|
with open("./deb2gen_mapping.list") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
d, g = line.strip().split('\t')
|
d, g = line.strip().split('\t')
|
||||||
if deb2gen.get(d):
|
|
||||||
deb2gen[d].append(g)
|
deb2gen[d].append(g)
|
||||||
else:
|
|
||||||
deb2gen[d] = [g]
|
|
||||||
if gen2deb.get(g):
|
|
||||||
gen2deb[g].append(d)
|
gen2deb[g].append(d)
|
||||||
else:
|
|
||||||
gen2deb[g] = [d]
|
|
||||||
|
|
||||||
with open("./deb_source_pkgs.list") as f:
|
with open("./deb_source_pkgs.list") as f:
|
||||||
debian_names = [p[4:].strip() for p in f]
|
debian_names = [p[4:].strip() for p in f]
|
||||||
|
|
Loading…
Reference in a new issue