Use collections.Counter instead of manually
This commit is contained in:
parent
8de6168ae4
commit
d9a5257255
1 changed files with 4 additions and 9 deletions
|
@ -8,7 +8,7 @@ if len(sys.argv) != 2:
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from os import path
|
from os import path
|
||||||
from collections import defaultdict
|
from collections import Counter, 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
|
||||||
|
@ -208,12 +208,7 @@ for d in debian_names:
|
||||||
|
|
||||||
sys.stderr.write("%s\n%s\n"%(list(set(missing_deb_mappings)),list(set(missing_gen_mappings))))
|
sys.stderr.write("%s\n%s\n"%(list(set(missing_deb_mappings)),list(set(missing_gen_mappings))))
|
||||||
|
|
||||||
drop_freq = dict()
|
drop_freq = Counter(all_droppable)
|
||||||
for p in all_droppable:
|
|
||||||
if drop_freq.get(p):
|
|
||||||
drop_freq[p] += 1
|
|
||||||
else:
|
|
||||||
drop_freq[p] = 1
|
|
||||||
|
|
||||||
for k in sorted(drop_freq.keys(), key=drop_freq.__getitem__, reverse=True)[:20]:
|
for package, freq in drop_freq.most_common(20):
|
||||||
sys.stderr.write("%s: %s\n"%(k, drop_freq[k]))
|
sys.stderr.write("%s: %s\n"%(package, freq))
|
||||||
|
|
Loading…
Reference in a new issue