From 8f38bc72301fee88487a88e19c6e7f7c808f7486 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 4 Jun 2020 13:43:31 +0930 Subject: [PATCH] pyln.proto.message: support adding two namespaces. They must not have duplicate names! Signed-off-by: Rusty Russell --- contrib/pyln-proto/pyln/proto/message/message.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contrib/pyln-proto/pyln/proto/message/message.py b/contrib/pyln-proto/pyln/proto/message/message.py index 3877a117e..6aaedccb9 100644 --- a/contrib/pyln-proto/pyln/proto/message/message.py +++ b/contrib/pyln-proto/pyln/proto/message/message.py @@ -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: