pyln.proto.message: support adding two namespaces.

They must not have duplicate names!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2020-06-04 13:43:31 +09:30 committed by Christian Decker
parent 85bb93618b
commit 8f38bc7230

View File

@ -21,6 +21,19 @@ domain, such as within a given BOLT"""
self.load_csv(csv_lines)
def __add__(self, other):
ret = MessageNamespace()
ret.subtypes = self.subtypes.copy()
for v in other.subtypes.values():
ret.add_subtype(v)
ret.tlvtypes = self.tlvtypes.copy()
for v in other.tlvtypes.values():
ret.add_tlvtype(v)
ret.messagetypes = self.messagetypes.copy()
for v in other.messagetypes.values():
ret.add_messagetype(v)
return ret
def add_subtype(self, t):
prev = self.get_type(t.name)
if prev: