MCPcopy Create free account
hub / github.com/comaps/comaps / apply_diff

Function apply_diff

tools/python/stylesheet/drules_merge.py:85–105  ·  view source on GitHub ↗

Applies diff tuple (from create_diff) to a drules set.

(drules, diff)

Source from the content-addressed store, hash-verified

83 return (add_elements_low, add_elements_high, add_types)
84
85def apply_diff(drules, diff):
86 """Applies diff tuple (from create_diff) to a drules set."""
87 d2pos = 0
88 result = drules_struct_pb2.ContainerProto()
89 for rule in drules.cont:
90 typ = str(rule.name)
91 # Append rules from diff[2] which nas name less than typ
92 while d2pos < len(diff[2]) and diff[2][d2pos].name < typ:
93 result.cont.extend([diff[2][d2pos]])
94 d2pos += 1
95 fix = drules_struct_pb2.ClassifElementProto()
96 fix.name = typ
97 if typ in diff[0]:
98 fix.element.extend(diff[0][typ])
99 if rule.element:
100 fix.element.extend(rule.element)
101 if typ in diff[1]:
102 fix.element.extend(diff[1][typ])
103 result.cont.extend([fix])
104 result.cont.extend(diff[2][d2pos:])
105 return result
106
107if __name__ == '__main__':
108 if len(sys.argv) <= 3:

Callers 1

drules_merge.pyFile · 0.85

Calls 2

ContainerProtoMethod · 0.80
ClassifElementProtoMethod · 0.80

Tested by

no test coverage detected