Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try:
- from collections.abc import Mapping
- from collections.abc import Sequence
- except ImportError:
- from collections import Mapping
- from collections import Sequence
- import six
- def foo(desire, current):
- if isinstance(desire, Mapping):
- return isinstance(current, Mapping) and all(
- foo(val, current.get(key))
- for key, val in six.viewitems(desire)
- )
- elif isinstance(desire, Sequence) and not isinstance(
- desire, six.string_types
- ):
- return (
- isinstance(current, Sequence)
- and not isinstance(current, six.string_types)
- and len(current) == len(desire)
- and all(foo(d, c) for d, c in zip(desire, current))
- )
- else:
- return desire == current
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement