Revision 92389be9

b/autotools/build-rpc
195 195
    assert module.SINGLE == _SINGLE
196 196
    assert module.MULTI == _MULTI
197 197

  
198
    dups = utils.FindDuplicates(itertools.chain(*map(lambda value: value.keys(),
199
                                                     module.CALLS.values())))
198
    dups = utils.GetRepeatedKeys(*module.CALLS.values())
200 199
    if dups:
201 200
      raise Exception("Found duplicate RPC definitions for '%s'" %
202 201
                      utils.CommaJoin(sorted(dups)))
b/lib/utils/algo.py
95 95
  return list(dup)
96 96

  
97 97

  
98
#pylint: disable=W0142 (use of *-magic in argument list)
99
def GetRepeatedKeys(*dicts):
100
  """Return the set of keys defined multiple times in the given dicts.
101

  
102
  >>> GetRepeatedKeys({"foo": 1, "bar": 2},
103
  ...                 {"foo": 5, "baz": 7}
104
  ...                )
105
  set("foo")
106

  
107
  @type dicts: dict
108
  @param dicts: The dictionaries to check for duplicate keys.
109
  @rtype: set
110
  @return: Keys used more than once across all dicts
111

  
112
  """
113
  if len(dicts) < 2:
114
    return set()
115

  
116
  keys = []
117
  for dictionary in dicts:
118
    keys.extend(dictionary)
119

  
120
  return set(FindDuplicates(keys))
121

  
122

  
98 123
def _NiceSortTryInt(val):
99 124
  """Attempts to convert a string to an integer.
100 125

  

Also available in: Unified diff