Skip to content

Commit

Permalink
Update zamxml conformance skip (project-chip#36306)
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 authored Oct 31, 2024
1 parent d38d56b commit 6aa13c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,7 @@ def GetNextProcessor(self, name: str, attrs: AttributesImpl):
if "nullable" in attrs and attrs["nullable"] != "false":
self._attribute.definition.qualities |= FieldQuality.NULLABLE
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
elif name == "optionalConform":
self._attribute.definition.qualities |= FieldQuality.OPTIONAL
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
elif name == "otherwiseConform":
elif name in {"optionalConform", "otherwiseConform"}:
self._attribute.definition.qualities |= FieldQuality.OPTIONAL
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
elif name == "mandatoryConform":
Expand Down
27 changes: 26 additions & 1 deletion scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
LOGGER = logging.getLogger('matter-xml-parser')


def _IsConformanceTagName(name: str) -> bool:
return name in {'mandatoryConform', 'optionalConform', 'otherwiseConform', 'provisionalConform', 'deprecateConform'}


class ClusterNameHandler(BaseHandler):
"""Handles /configurator/cluster/name elements."""

Expand Down Expand Up @@ -110,6 +114,9 @@ def GetNextProcessor(self, name: str, attrs):
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
elif name.lower() == 'description':
return DescriptionHandler(self.context, self._event)
elif _IsConformanceTagName(name):
# we do not parse conformance at this point
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
else:
return BaseHandler(self.context)

Expand Down Expand Up @@ -145,6 +152,9 @@ def GetNextProcessor(self, name: str, attrs):
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
elif name.lower() == 'description':
return AttributeDescriptionHandler(self.context, self._attribute)
elif _IsConformanceTagName(name):
# we do not parse conformance at this point
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
else:
return BaseHandler(self.context)

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


class SkipProvisioalHandler(BaseHandler):
def __init__(self, context: Context, attrs):
super().__init__(context, handled=HandledDepth.SINGLE_TAG)

def GetNextProcessor(self, name: str, attrs):
if _IsConformanceTagName(name):
# we do not parse conformance at this point
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
else:
return BaseHandler(self.context)


class StructHandler(BaseHandler, IdlPostProcessor):
""" Handling /configurator/struct elements."""

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

self._struct.fields.append(field)
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
return SkipProvisioalHandler(self.context, attrs)
elif name.lower() == 'cluster':
self._cluster_codes.add(ParseInt(attrs['code']))
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
Expand Down Expand Up @@ -460,6 +482,9 @@ def GetNextProcessor(self, name: str, attrs):
if self._command:
return DescriptionHandler(self.context, self._command)
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
elif _IsConformanceTagName(name):
# we do not parse conformance at this point
return BaseHandler(self.context, handled=HandledDepth.ENTIRE_TREE)
else:
return BaseHandler(self.context)

Expand Down

0 comments on commit 6aa13c0

Please sign in to comment.