|
| 1 | +# |
| 2 | +# Copyright (c) 2024 Project CHIP Authors |
| 3 | +# All rights reserved. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | +# |
| 17 | + |
| 18 | +import os |
| 19 | + |
| 20 | +cluster_to_pics_dict = { |
| 21 | + # Name mapping due to inconsistent naming of PICS files |
| 22 | + "ICDManagement": "ICD Management", |
| 23 | + "OTA Software Update Provider": "OTA Software Update", |
| 24 | + "OTA Software Update Requestor": "OTA Software Update", |
| 25 | + "On/Off": "On-Off", |
| 26 | + "GroupKeyManagement": "Group Communication", |
| 27 | + "Wake on LAN": "Media Cluster", |
| 28 | + "Low Power": "Media Cluster", |
| 29 | + "Keypad Input": "Media Cluster", |
| 30 | + "Audio Output": "Media Cluster", |
| 31 | + "Media Input": "Media Cluster", |
| 32 | + "Target Navigator": "Media Cluster", |
| 33 | + "Content Control": "Media Cluster", |
| 34 | + "Channel": "Media Cluster", |
| 35 | + "Media Playback": "Media Cluster", |
| 36 | + "Account Login": "Media Cluster", |
| 37 | + "Application Basic": "Media Cluster", |
| 38 | + "Content Launcher": "Media Cluster", |
| 39 | + "Content App Observer": "Media Cluster", |
| 40 | + "Application Launch": "Media Cluster", |
| 41 | + "Operational Credentials": "Node Operational Credentials", |
| 42 | + |
| 43 | + # Workaround for naming colisions with current logic |
| 44 | + "Thermostat": "Thermostat Cluster", |
| 45 | + "Boolean State": "Boolean State Cluster", |
| 46 | + "AccessControl": "Access Control Cluster", |
| 47 | +} |
| 48 | + |
| 49 | + |
| 50 | +def pics_xml_file_list_loader(pics_xml_path: str, log_loaded_pics_files: bool) -> list: |
| 51 | + |
| 52 | + pics_xml_file_list = os.listdir(pics_xml_path) |
| 53 | + |
| 54 | + if log_loaded_pics_files: |
| 55 | + if not pics_xml_path.endswith('/'): |
| 56 | + pics_xml_path += '/' |
| 57 | + |
| 58 | + for pics_xml_file in pics_xml_file_list: |
| 59 | + print(f"{pics_xml_path}/{pics_xml_file}") |
| 60 | + |
| 61 | + return pics_xml_file_list |
| 62 | + |
| 63 | + |
| 64 | +def map_cluster_name_to_pics_xml(cluster_name, pics_xml_file_list) -> str: |
| 65 | + file_name = "" |
| 66 | + |
| 67 | + pics_file_name = cluster_to_pics_dict.get(cluster_name, cluster_name) |
| 68 | + |
| 69 | + for file in pics_xml_file_list: |
| 70 | + if file.lower().startswith(pics_file_name.lower()): |
| 71 | + file_name = file |
| 72 | + break |
| 73 | + |
| 74 | + return file_name |
0 commit comments