Commit 92389be9 authored by Santi Raffa's avatar Santi Raffa Committed by Jose A. Lopes
Browse files

algo: add GetRepeatedKeys

We do not want public, private and secret parameters to have
overlapping keys. This function implements this check.
Signed-off-by: default avatarSanti Raffa <>
Reviewed-by: default avatarJose A. Lopes <>
parent 9d929656
......@@ -195,8 +195,7 @@ def main():
assert module.SINGLE == _SINGLE
assert module.MULTI == _MULTI
dups = utils.FindDuplicates(itertools.chain(*map(lambda value: value.keys(),
dups = utils.GetRepeatedKeys(*module.CALLS.values())
if dups:
raise Exception("Found duplicate RPC definitions for '%s'" %
......@@ -95,6 +95,31 @@ def FindDuplicates(seq):
return list(dup)
#pylint: disable=W0142 (use of *-magic in argument list)
def GetRepeatedKeys(*dicts):
"""Return the set of keys defined multiple times in the given dicts.
>>> GetRepeatedKeys({"foo": 1, "bar": 2},
... {"foo": 5, "baz": 7}
... )
@type dicts: dict
@param dicts: The dictionaries to check for duplicate keys.
@rtype: set
@return: Keys used more than once across all dicts
if len(dicts) < 2:
return set()
keys = []
for dictionary in dicts:
return set(FindDuplicates(keys))
def _NiceSortTryInt(val):
"""Attempts to convert a string to an integer.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment