~ubuntu-langpack/langpack-o-matic/main

« back to all changes in this revision

Viewing changes to import

  • Committer: Łukasz 'sil2100' Zemczak
  • Date: 2016-04-11 13:16:05 UTC
  • mfrom: (559.1.2 langpack-o-matic)
  • Revision ID: lukasz.zemczak@canonical.com-20160411131605-zqvkl2u05u7e9c0s
Mapping files can have multiple entries for domains - treat each entry as a list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
    '''Return set of domains corresponding to packages list'''
102
102
 
103
103
    # read domain map.txt
104
 
    pkg_domain = {}
 
104
    pkg_domains = {}
105
105
    with open(map_file) as f:
106
106
        for line in f:
107
107
            f = line.split()
108
108
            if len(f) != 2:
109
109
                continue
110
 
            pkg_domain[f[0]] = f[1]
 
110
            pkg_domains.setdefault(f[0], []).append(f[1])
111
111
 
112
112
    domains = set()
113
113
    with open(packages) as f:
115
115
            pkg = line.strip()
116
116
            if not pkg:
117
117
                continue
118
 
            try:
119
 
                domains.add(pkg_domain[pkg])
120
 
            except KeyError:
 
118
            if pkg in pkg_domains:
 
119
                domains.update(pkg_domains[pkg])
 
120
            else:
121
121
                logging.debug('package %s is in --pkglist, but not in mapping.txt', pkg)
122
122
    return domains
123
123