Skip to content

Commit a35ca78

Browse files
authoredMar 24, 2025··
Update PICS Generator tool (#37901)
* Add dm input tag to align with updated build_xml_clusters usage * Fix restyle issues
1 parent 2c7bc31 commit a35ca78

File tree

4 files changed

+34
-4
lines changed

4 files changed

+34
-4
lines changed
 

‎src/tools/PICS-generator/PICSGenerator.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import pathlib
2121
import sys
2222
import xml.etree.ElementTree as ET
23+
from pathlib import Path
2324

2425
import chip.clusters as Clusters
2526
from pics_generator_support import map_cluster_name_to_pics_xml, pics_xml_file_list_loader
@@ -28,7 +29,7 @@
2829
# Add the path to python_testing folder, in order to be able to import from chip.testing.matter_testing
2930
sys.path.append(os.path.abspath(sys.path[0] + "/../../python_testing"))
3031
from chip.testing.matter_testing import MatterBaseTest, async_test_body, default_matter_test_main # noqa: E402
31-
from chip.testing.spec_parsing import build_xml_clusters # noqa: E402
32+
from chip.testing.spec_parsing import PrebuiltDataModelDirectory, build_xml_clusters # noqa: E402
3233

3334
console = None
3435
xml_clusters = None
@@ -360,6 +361,7 @@ def cleanDirectory(pathToClean):
360361
parser = argparse.ArgumentParser()
361362
parser.add_argument('--pics-template', required=True)
362363
parser.add_argument('--pics-output', required=True)
364+
parser.add_argument('--dm-xml')
363365
args, unknown = parser.parse_known_args()
364366

365367
xmlTemplatePathStr = args.pics_template
@@ -414,7 +416,10 @@ async def test_device_mapping(self):
414416
console = Console()
415417

416418
global xml_clusters
417-
xml_clusters, problems = build_xml_clusters()
419+
if args.dm_xml:
420+
xml_clusters, problems = build_xml_clusters(Path(f"{args.dm_xml}/clusters"))
421+
else:
422+
xml_clusters, problems = build_xml_clusters(PrebuiltDataModelDirectory.kMaster)
418423

419424
# Run device mapping function
420425
await DeviceMapping(self.default_controller, self.dut_node_id, outputPathStr)

‎src/tools/PICS-generator/README.md

+18
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ If a device has already been commissioned, the tool can be executed like this:
8686
python3 PICSGenerator.py --pics-template <pathToPicsTemplateFolder> --pics-output <outputPath>
8787
```
8888

89+
The tool can be used to validate against the available spec versions, this can
90+
be done by providing the following tag in the command, if no path is provided it
91+
will use the current scrape of Master. An example path is
92+
"connectedhomeip/data_model/master".
93+
94+
```
95+
python3 PICSGenerator.py --pics-template <pathToPicsTemplateFolder> --dm <pathToDmScrapeFolder>
96+
```
97+
8998
# Updates for future releases
9099

91100
Given each new release adds PICS files, to ensure the tool is able to map the
@@ -102,3 +111,12 @@ To run the XMLPICSValidator, the following command can be used:
102111
```
103112
python3 XMLPICSValidator.py --pics-template <pathToPicsTemplateFolder>
104113
```
114+
115+
The tool can be used to validate against the available spec versions, this can
116+
be done by providing the following tag in the command, if no path is provided it
117+
will use the current scrape of Master. An example path is
118+
"connectedhomeip/data_model/master".
119+
120+
```
121+
python3 XMLPICSValidator.py --pics-template <pathToPicsTemplateFolder> --dm <pathToDmScrapeFolder>
122+
```

‎src/tools/PICS-generator/XMLPICSValidator.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,17 @@
1818
import argparse
1919
import os
2020
import sys
21+
from pathlib import Path
2122

2223
from pics_generator_support import map_cluster_name_to_pics_xml, pics_xml_file_list_loader
2324

2425
# Add the path to python_testing folder, in order to be able to import from matter_testing_support
2526
sys.path.append(os.path.abspath(sys.path[0] + "/../../python_testing"))
26-
from chip.testing.spec_parsing import build_xml_clusters # noqa: E402
27+
from chip.testing.spec_parsing import PrebuiltDataModelDirectory, build_xml_clusters # noqa: E402
2728

2829
parser = argparse.ArgumentParser()
2930
parser.add_argument('--pics-template', required=True)
31+
parser.add_argument('--dm-xml')
3032
args, unknown = parser.parse_known_args()
3133

3234
xml_template_path_str = args.pics_template
@@ -35,7 +37,11 @@
3537
pics_xml_file_list = pics_xml_file_list_loader(xml_template_path_str, True)
3638

3739
print("Build list of spec XML")
38-
xml_clusters, problems = build_xml_clusters()
40+
if args.dm_xml:
41+
xml_clusters, problems = build_xml_clusters(Path(f"{args.dm_xml}/clusters"))
42+
else:
43+
xml_clusters, problems = build_xml_clusters(PrebuiltDataModelDirectory.kMaster)
44+
3945

4046
for cluster in xml_clusters:
4147
pics_xml_file_name = map_cluster_name_to_pics_xml(xml_clusters[cluster].name, pics_xml_file_list)

‎src/tools/PICS-generator/pics_generator_support.py

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"OTA Software Update Requestor": "OTA Software Update",
2525
"On/Off": "On-Off",
2626
"GroupKeyManagement": "Group Communication",
27+
"Wake On LAN": "Media Cluster",
2728
"Wake on LAN": "Media Cluster",
2829
"Low Power": "Media Cluster",
2930
"Keypad Input": "Media Cluster",

0 commit comments

Comments
 (0)
Please sign in to comment.