MCPcopy Index your code
hub / github.com/docopt/docopt / fix_identities

Method fix_identities

docopt.py:45–55  ·  view source on GitHub ↗

Make pattern-tree tips point to same object if they are equal.

(self, uniq=None)

Source from the content-addressed store, hash-verified

43 return self
44
45 def fix_identities(self, uniq=None):
46 """Make pattern-tree tips point to same object if they are equal."""
47 if not hasattr(self, 'children'):
48 return self
49 uniq = list(set(self.flat())) if uniq is None else uniq
50 for i, c in enumerate(self.children):
51 if not hasattr(c, 'children'):
52 assert c in uniq
53 self.children[i] = uniq[uniq.index(c)]
54 else:
55 c.fix_identities(uniq)
56
57 def fix_repeating_arguments(self):
58 """Fix elements that should accumulate/increment values."""

Callers 3

fixMethod · 0.95

Calls 1

flatMethod · 0.45

Tested by 2