Skip to content

Commit 6aa13c0

Browse files
authored
Update zamxml conformance skip (#36306)
1 parent d38d56b commit 6aa13c0

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

scripts/py_matter_idl/matter_idl/data_model_xml/handlers/handlers.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,7 @@ def GetNextProcessor(self, name: str, attrs: AttributesImpl):
343343
if "nullable" in attrs and attrs["nullable"] != "false":
344344
self._attribute.definition.qualities |= FieldQuality.NULLABLE
345345
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
346-
elif name == "optionalConform":
347-
self._attribute.definition.qualities |= FieldQuality.OPTIONAL
348-
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
349-
elif name == "otherwiseConform":
346+
elif name in {"optionalConform", "otherwiseConform"}:
350347
self._attribute.definition.qualities |= FieldQuality.OPTIONAL
351348
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
352349
elif name == "mandatoryConform":

scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py

+26-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
LOGGER = logging.getLogger('matter-xml-parser')
2626

2727

28+
def _IsConformanceTagName(name: str) -> bool:
29+
return name in {'mandatoryConform', 'optionalConform', 'otherwiseConform', 'provisionalConform', 'deprecateConform'}
30+
31+
2832
class ClusterNameHandler(BaseHandler):
2933
"""Handles /configurator/cluster/name elements."""
3034

@@ -110,6 +114,9 @@ def GetNextProcessor(self, name: str, attrs):
110114
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
111115
elif name.lower() == 'description':
112116
return DescriptionHandler(self.context, self._event)
117+
elif _IsConformanceTagName(name):
118+
# we do not parse conformance at this point
119+
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
113120
else:
114121
return BaseHandler(self.context)
115122

@@ -145,6 +152,9 @@ def GetNextProcessor(self, name: str, attrs):
145152
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
146153
elif name.lower() == 'description':
147154
return AttributeDescriptionHandler(self.context, self._attribute)
155+
elif _IsConformanceTagName(name):
156+
# we do not parse conformance at this point
157+
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
148158
else:
149159
return BaseHandler(self.context)
150160

@@ -162,6 +172,18 @@ def EndProcessing(self):
162172
self._cluster.attributes.append(self._attribute)
163173

164174

175+
class SkipProvisioalHandler(BaseHandler):
176+
def __init__(self, context: Context, attrs):
177+
super().__init__(context, handled=HandledDepth.SINGLE_TAG)
178+
179+
def GetNextProcessor(self, name: str, attrs):
180+
if _IsConformanceTagName(name):
181+
# we do not parse conformance at this point
182+
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
183+
else:
184+
return BaseHandler(self.context)
185+
186+
165187
class StructHandler(BaseHandler, IdlPostProcessor):
166188
""" Handling /configurator/struct elements."""
167189

@@ -213,7 +235,7 @@ def GetNextProcessor(self, name: str, attrs):
213235
field.qualities |= FieldQuality.FABRIC_SENSITIVE
214236

215237
self._struct.fields.append(field)
216-
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
238+
return SkipProvisioalHandler(self.context, attrs)
217239
elif name.lower() == 'cluster':
218240
self._cluster_codes.add(ParseInt(attrs['code']))
219241
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
@@ -460,6 +482,9 @@ def GetNextProcessor(self, name: str, attrs):
460482
if self._command:
461483
return DescriptionHandler(self.context, self._command)
462484
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
485+
elif _IsConformanceTagName(name):
486+
# we do not parse conformance at this point
487+
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
463488
else:
464489
return BaseHandler(self.context)
465490

0 commit comments

Comments
 (0)