Merge lp:~sil2100/langpack-o-matic/domains_as_lists into lp:langpack-o-matic

Proposed by Łukasz Zemczak on 2016-04-11
Status: Merged
Merged at revision: 560
Proposed branch: lp:~sil2100/langpack-o-matic/domains_as_lists
Merge into: lp:langpack-o-matic
Diff against target: 31 lines (+5/-5)
1 file modified
import (+5/-5)
To merge this branch: bzr merge lp:~sil2100/langpack-o-matic/domains_as_lists
Reviewer Review Type Date Requested Status
Ubuntu language pack builders 2016-04-11 Pending
Review via email: mp+291493@code.launchpad.net

Commit Message

Mapping files can have multiple entries for one domain - tread each entry as a list.

Description of the Change

Mapping files can have multiple entries for one domain - tread each entry as a list.

Had to switch off from the KeyError route as we're using a defaultdict now. Tested this locally and it seemed to work properly this time.

To post a comment you must log in.
Martin Pitt (pitti) wrote :

Looks mostly good to me, except for a stylistic issue (see inline comment). If that passes the tests (tests/run), please go ahead.

561. By Łukasz Zemczak on 2016-04-11

As per pitti's request, do not use collections defaultdict, rename pkg_domain to pkg_domains.

Łukasz Zemczak (sil2100) wrote :

Tests are passing. Merging this, thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'import'
2--- import 2016-03-31 09:29:25 +0000
3+++ import 2016-04-11 12:59:53 +0000
4@@ -101,13 +101,13 @@
5 '''Return set of domains corresponding to packages list'''
6
7 # read domain map.txt
8- pkg_domain = {}
9+ pkg_domains = {}
10 with open(map_file) as f:
11 for line in f:
12 f = line.split()
13 if len(f) != 2:
14 continue
15- pkg_domain[f[0]] = f[1]
16+ pkg_domains.setdefault(f[0], []).append(f[1])
17
18 domains = set()
19 with open(packages) as f:
20@@ -115,9 +115,9 @@
21 pkg = line.strip()
22 if not pkg:
23 continue
24- try:
25- domains.add(pkg_domain[pkg])
26- except KeyError:
27+ if pkg in pkg_domains:
28+ domains.update(pkg_domains[pkg])
29+ else:
30 logging.debug('package %s is in --pkglist, but not in mapping.txt', pkg)
31 return domains
32

Subscribers

People subscribed via source and target branches