Update PICS Generator tool (#37901)
* Add dm input tag to align with updated build_xml_clusters usage
* Fix restyle issues
diff --git a/src/tools/PICS-generator/PICSGenerator.py b/src/tools/PICS-generator/PICSGenerator.py
index 6cfb958..3e2bbe5 100644
--- a/src/tools/PICS-generator/PICSGenerator.py
+++ b/src/tools/PICS-generator/PICSGenerator.py
@@ -20,6 +20,7 @@
import pathlib
import sys
import xml.etree.ElementTree as ET
+from pathlib import Path
import chip.clusters as Clusters
from pics_generator_support import map_cluster_name_to_pics_xml, pics_xml_file_list_loader
@@ -28,7 +29,7 @@
# Add the path to python_testing folder, in order to be able to import from chip.testing.matter_testing
sys.path.append(os.path.abspath(sys.path[0] + "/../../python_testing"))
from chip.testing.matter_testing import MatterBaseTest, async_test_body, default_matter_test_main # noqa: E402
-from chip.testing.spec_parsing import build_xml_clusters # noqa: E402
+from chip.testing.spec_parsing import PrebuiltDataModelDirectory, build_xml_clusters # noqa: E402
console = None
xml_clusters = None
@@ -360,6 +361,7 @@
parser = argparse.ArgumentParser()
parser.add_argument('--pics-template', required=True)
parser.add_argument('--pics-output', required=True)
+parser.add_argument('--dm-xml')
args, unknown = parser.parse_known_args()
xmlTemplatePathStr = args.pics_template
@@ -414,7 +416,10 @@
console = Console()
global xml_clusters
- xml_clusters, problems = build_xml_clusters()
+ if args.dm_xml:
+ xml_clusters, problems = build_xml_clusters(Path(f"{args.dm_xml}/clusters"))
+ else:
+ xml_clusters, problems = build_xml_clusters(PrebuiltDataModelDirectory.kMaster)
# Run device mapping function
await DeviceMapping(self.default_controller, self.dut_node_id, outputPathStr)
diff --git a/src/tools/PICS-generator/README.md b/src/tools/PICS-generator/README.md
index 312d790..79579d5 100644
--- a/src/tools/PICS-generator/README.md
+++ b/src/tools/PICS-generator/README.md
@@ -86,6 +86,15 @@
python3 PICSGenerator.py --pics-template <pathToPicsTemplateFolder> --pics-output <outputPath>
```
+The tool can be used to validate against the available spec versions, this can
+be done by providing the following tag in the command, if no path is provided it
+will use the current scrape of Master. An example path is
+"connectedhomeip/data_model/master".
+
+```
+python3 PICSGenerator.py --pics-template <pathToPicsTemplateFolder> --dm <pathToDmScrapeFolder>
+```
+
# Updates for future releases
Given each new release adds PICS files, to ensure the tool is able to map the
@@ -102,3 +111,12 @@
```
python3 XMLPICSValidator.py --pics-template <pathToPicsTemplateFolder>
```
+
+The tool can be used to validate against the available spec versions, this can
+be done by providing the following tag in the command, if no path is provided it
+will use the current scrape of Master. An example path is
+"connectedhomeip/data_model/master".
+
+```
+python3 XMLPICSValidator.py --pics-template <pathToPicsTemplateFolder> --dm <pathToDmScrapeFolder>
+```
diff --git a/src/tools/PICS-generator/XMLPICSValidator.py b/src/tools/PICS-generator/XMLPICSValidator.py
index 5fd1704..b3a98d6 100644
--- a/src/tools/PICS-generator/XMLPICSValidator.py
+++ b/src/tools/PICS-generator/XMLPICSValidator.py
@@ -18,15 +18,17 @@
import argparse
import os
import sys
+from pathlib import Path
from pics_generator_support import map_cluster_name_to_pics_xml, pics_xml_file_list_loader
# Add the path to python_testing folder, in order to be able to import from matter_testing_support
sys.path.append(os.path.abspath(sys.path[0] + "/../../python_testing"))
-from chip.testing.spec_parsing import build_xml_clusters # noqa: E402
+from chip.testing.spec_parsing import PrebuiltDataModelDirectory, build_xml_clusters # noqa: E402
parser = argparse.ArgumentParser()
parser.add_argument('--pics-template', required=True)
+parser.add_argument('--dm-xml')
args, unknown = parser.parse_known_args()
xml_template_path_str = args.pics_template
@@ -35,7 +37,11 @@
pics_xml_file_list = pics_xml_file_list_loader(xml_template_path_str, True)
print("Build list of spec XML")
-xml_clusters, problems = build_xml_clusters()
+if args.dm_xml:
+ xml_clusters, problems = build_xml_clusters(Path(f"{args.dm_xml}/clusters"))
+else:
+ xml_clusters, problems = build_xml_clusters(PrebuiltDataModelDirectory.kMaster)
+
for cluster in xml_clusters:
pics_xml_file_name = map_cluster_name_to_pics_xml(xml_clusters[cluster].name, pics_xml_file_list)
diff --git a/src/tools/PICS-generator/pics_generator_support.py b/src/tools/PICS-generator/pics_generator_support.py
index 53e0248..af58511 100644
--- a/src/tools/PICS-generator/pics_generator_support.py
+++ b/src/tools/PICS-generator/pics_generator_support.py
@@ -24,6 +24,7 @@
"OTA Software Update Requestor": "OTA Software Update",
"On/Off": "On-Off",
"GroupKeyManagement": "Group Communication",
+ "Wake On LAN": "Media Cluster",
"Wake on LAN": "Media Cluster",
"Low Power": "Media Cluster",
"Keypad Input": "Media Cluster",