/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/plugins/fastimport/helpers.py

  • Committer: Jelmer Vernooij
  • Date: 2018-03-24 17:48:04 UTC
  • mfrom: (6921 work)
  • mto: This revision was merged to the branch mainline in revision 6923.
  • Revision ID: jelmer@jelmer.uk-20180324174804-xf22o05byoj12x1q
Merge trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
178
178
        return single
179
179
    else:
180
180
        return plural
 
181
 
 
182
 
 
183
def invert_dictset(d):
 
184
    """Invert a dictionary with keys matching a set of values, turned into lists."""
 
185
    # Based on recipe from ASPN
 
186
    result = {}
 
187
    for k, c in d.items():
 
188
        for v in c:
 
189
            keys = result.setdefault(v, [])
 
190
            keys.append(k)
 
191
    return result
 
192
 
 
193
 
 
194
def invert_dict(d):
 
195
    """Invert a dictionary with keys matching each value turned into a list."""
 
196
    # Based on recipe from ASPN
 
197
    result = {}
 
198
    for k, v in d.items():
 
199
        keys = result.setdefault(v, [])
 
200
        keys.append(k)
 
201
    return result
 
202
 
 
203