Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PICS Generator to 1.4 #35619

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 36 additions & 19 deletions src/tools/PICS-generator/PICSGenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,47 +42,62 @@ def GenerateDevicePicsXmlFiles(clusterName, clusterPicsCode, featurePicsList, at

# Map clusters to common XML template if needed
if "ICDManagement" == clusterName:
clusterName = "ICD Management"
picsFileName = "ICD Management"

elif "OTA Software Update Provider" in clusterName or "OTA Software Update Requestor" in clusterName:
clusterName = "OTA Software Update"
elif "OTA Software Update Provider" in clusterName or \
"OTA Software Update Requestor" in clusterName:
picsFileName = "OTA Software Update"

elif "On/Off" == clusterName:
clusterName = clusterName.replace("/", "-")
picsFileName = clusterName.replace("/", "-")

elif "GroupKeyManagement" == clusterName:
clusterName = "Group Communication"

elif "Wake On LAN" == clusterName or "Low Power" == clusterName:
clusterName = "Media Cluster"
picsFileName = "Group Communication"

elif "Wake on LAN" == clusterName or \
"Low Power" == clusterName or \
"Keypad Input" == clusterName or \
"Audio Output" == clusterName or \
"Media Input" == clusterName or \
"Target Navigator" == clusterName or \
"Content Control" == clusterName or \
"Channel" == clusterName or \
"Media Playback" == clusterName or \
"Account Login" == clusterName or \
"Application Basic" == clusterName or \
"Content Launcher" == clusterName or \
"Content App Observer" == clusterName or \
"Application Launcher" == clusterName:

picsFileName = "Media Cluster"

elif "Operational Credentials" == clusterName:
clusterName = "Node Operational Credentials"

elif "Laundry Washer Controls" == clusterName:
clusterName = "Washer Controls"
picsFileName = "Node Operational Credentials"

# Workaround for naming colisions with current logic
elif "Thermostat" == clusterName:
clusterName = "Thermostat Cluster"
picsFileName = "Thermostat Cluster"

elif "Boolean State" == clusterName:
clusterName = "Boolean State Cluster"
picsFileName = "Boolean State Cluster"

elif "AccessControl" in clusterName:
picsFileName = "Access Control Cluster"

if "AccessControl" in clusterName:
clusterName = "Access Control cluster"
else:
picsFileName = clusterName

# Determine if file has already been handled and use this file
for outputFolderFileName in os.listdir(outputPathStr):
if clusterName in outputFolderFileName:
if picsFileName in outputFolderFileName:
xmlPath = outputPathStr
fileName = outputFolderFileName
break

# If no file is found in output folder, determine if there is a match for the cluster name in input folder
if fileName == "":
for file in xmlFileList:
if file.lower().startswith(clusterName.lower()):
if file.lower().startswith(picsFileName.lower()):
fileName = file
break
else:
Expand Down Expand Up @@ -421,9 +436,11 @@ def cleanDirectory(pathToClean):
# Load PICS XML templates
print("Capture list of PICS XML templates")
xmlFileList = os.listdir(xmlTemplatePathStr)
for PICSXmlFile in xmlFileList:
print(f"{xmlTemplatePathStr}/{PICSXmlFile}")

# Setup output path
print(outputPathStr)
print(f"Output path: {outputPathStr}")

outputPath = pathlib.Path(outputPathStr)
if not outputPath.exists():
Expand Down
122 changes: 122 additions & 0 deletions src/tools/PICS-generator/XMLPICSValidator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
# Copyright (c) 2023 Project CHIP Authors
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import argparse
import os
import sys

from rich.console import Console

# 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 matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main # noqa: E402
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
from spec_parsing_support import build_xml_clusters # noqa: E402

console = None
xml_clusters = None

parser = argparse.ArgumentParser()
parser.add_argument('--pics-template', required=True)
args, unknown = parser.parse_known_args()

xmlTemplatePathStr = args.pics_template
if not xmlTemplatePathStr.endswith('/'):
xmlTemplatePathStr += '/'

# Load PICS XML templates
print("Capture list of PICS XML templates")
xmlFileList = os.listdir(xmlTemplatePathStr)
for PICSXmlFile in xmlFileList:
print(f"{xmlTemplatePathStr}/{PICSXmlFile}")


class XMLPICSValidator(MatterBaseTest):
@async_test_body
async def test_xml_pics_validator(self):

# Create console to print
global console
console = Console()
andy31415 marked this conversation as resolved.
Show resolved Hide resolved

global xml_clusters
xml_clusters, problems = build_xml_clusters()
andy31415 marked this conversation as resolved.
Show resolved Hide resolved

for cluster in xml_clusters:

fileName = ""
clusterName = xml_clusters[cluster].name

if "ICDManagement" == clusterName:
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
picsFileName = "ICD Management"

elif "OTA Software Update Provider" in clusterName or \
"OTA Software Update Requestor" in clusterName:
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
picsFileName = "OTA Software Update"

elif "On/Off" == clusterName:
picsFileName = clusterName.replace("/", "-")

elif "GroupKeyManagement" == clusterName:
picsFileName = "Group Communication"

elif "Wake on LAN" == clusterName or \
"Low Power" == clusterName or \
"Keypad Input" == clusterName or \
"Audio Output" == clusterName or \
"Media Input" == clusterName or \
"Target Navigator" == clusterName or \
"Content Control" == clusterName or \
"Channel" == clusterName or \
"Media Playback" == clusterName or \
"Account Login" == clusterName or \
"Application Basic" == clusterName or \
"Content Launcher" == clusterName or \
"Content App Observer" == clusterName or \
"Application Launcher" == clusterName:

picsFileName = "Media Cluster"

elif "Operational Credentials" == clusterName:
picsFileName = "Node Operational Credentials"

# Workaround for naming colisions with current logic
elif "Thermostat" == clusterName:
picsFileName = "Thermostat Cluster"

elif "Boolean State" == clusterName:
picsFileName = "Boolean State Cluster"

elif "AccessControl" in clusterName:
picsFileName = "Access Control Cluster"

else:
picsFileName = clusterName

for file in xmlFileList:
andy31415 marked this conversation as resolved.
Show resolved Hide resolved
if file.lower().startswith(picsFileName.lower()):
fileName = file
break

if fileName:
console.print(f"[blue]\"{clusterName}\" - \"{fileName}\" ✅")
else:
console.print(f"[red]Could not find matching file for \"{clusterName}\" ❌")
continue
andy31415 marked this conversation as resolved.
Show resolved Hide resolved


if __name__ == "__main__":
default_matter_test_main()
Loading