Skip to content

Commit

Permalink
Support a name attribute for XML tags for attributes in zapxml (pro…
Browse files Browse the repository at this point in the history
…ject-chip#36270)

* Add support for a name attribute in zapxml

* Add unit test
  • Loading branch information
andy31415 authored Oct 28, 2024
1 parent 2ba440b commit 41305b5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
27 changes: 27 additions & 0 deletions scripts/py_matter_idl/matter_idl/test_zapxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,33 @@ def testGlobalStruct(self):
)
self.assertEqual(idl, Idl(global_structs=[struct]))

def testNameAttribute(self):
idl = XmlToIdl('''<?xml version="1.0"?>
<configurator>
<cluster>
<name>TestCluster</name>
<code>20</code>
<attribute side="server" code="0x0002" name="SubjectsPerAccessControlEntry" define="SUBJECTS_PER_ACCESS_CONTROL_ENTRY" type="int16u" min="4" default="4">
<mandatoryConform/>
</attribute>
</cluster>
</configurator>
''')
self.assertEqual(idl,
Idl(clusters=[
Cluster(name='TestCluster', code=20,
attributes=[
Attribute(
definition=Field(
data_type=DataType(name='int16u', min_value=4),
code=2,
name='SubjectsPerAccessControlEntry',
),
qualities=AttributeQuality.READABLE,
readacl=AccessPrivilege.VIEW,
writeacl=AccessPrivilege.OPERATE)])]))

def testStruct(self):
idl = XmlToIdl('''<?xml version="1.0"?>
<configurator>
Expand Down
4 changes: 3 additions & 1 deletion scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ def AttrsToAttribute(attrs) -> Attribute:
if 'max' in attrs:
data_type.max_value = ParseInt(attrs['max'], data_type)

name = attrs['name'] if 'name' in attrs else ''

field = Field(
data_type=data_type,
code=ParseInt(attrs['code']),
name='',
name=name,
is_list=(attrs['type'].lower() == 'array')
)

Expand Down

0 comments on commit 41305b5

Please sign in to comment.