diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml
index 89e8c44d26a37f..3bfcc32bd9da4c 100644
--- a/.github/workflows/lint.yml
+++ b/.github/workflows/lint.yml
@@ -98,13 +98,13 @@ jobs:
if [ "$idl_file" = './examples/window-app/common/window-app.matter' ]; then continue; fi
# Test files are intentionally small and not spec-compilant, just parse-compliant
- if [ "$idl_file" = "./scripts/idl/tests/inputs/cluster_struct_attribute.matter" ]; then continue; fi
- if [ "$idl_file" = "./scripts/idl/tests/inputs/global_struct_attribute.matter" ]; then continue; fi
- if [ "$idl_file" = "./scripts/idl/tests/inputs/optional_argument.matter" ]; then continue; fi
- if [ "$idl_file" = "./scripts/idl/tests/inputs/several_clusters.matter" ]; then continue; fi
- if [ "$idl_file" = "./scripts/idl/tests/inputs/simple_attribute.matter" ]; then continue; fi
- if [ "$idl_file" = "./scripts/idl/tests/inputs/large_lighting_app.matter" ]; then continue; fi
- if [ "$idl_file" = "./scripts/idl/tests/inputs/large_all_clusters_app.matter" ]; then continue; fi
+ if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter" ]; then continue; fi
+ if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter" ]; then continue; fi
+ if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter" ]; then continue; fi
+ if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter" ]; then continue; fi
+ if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter" ]; then continue; fi
+ if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter" ]; then continue; fi
+ if [ "$idl_file" = "./scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter" ]; then continue; fi
./scripts/run_in_build_env.sh "./scripts/idl_lint.py --log-level warn $idl_file" >/dev/null || exit 1
done
diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml
index 7d35cde0db27ff..8f96c75a1e280b 100644
--- a/.github/workflows/tests.yaml
+++ b/.github/workflows/tests.yaml
@@ -105,7 +105,7 @@ jobs:
# things.
run: |
./scripts/run_in_build_env.sh \
- "./scripts/idl/xml_parser.py \
+ "./scripts/py_matter_idl/matter_idl/xml_parser.py \
--no-print \
--log-level info \
src/app/zap-templates/zcl/data-model/chip/global-attributes.xml \
diff --git a/.restyled.yaml b/.restyled.yaml
index 13d499b2b8967f..75b649d9e4242d 100644
--- a/.restyled.yaml
+++ b/.restyled.yaml
@@ -69,7 +69,7 @@ exclude:
- "third_party/android_deps/gradlew" # gradle wrapper generated file
- "src/controller/python/chip/clusters/Objects.py" # generated file, no point to restyle
- "src/controller/python/chip/clusters/CHIPClusters.py" # generated file, no point to restyle
- - "scripts/idl/tests/outputs/**/*" # Matches generated output 1:1
+ - "scripts/py_matter_idl/matter_idl/tests/outputs/**/*" # Matches generated output 1:1
- "examples/chef/sample_app_util/test_files/*.yaml"
- "examples/chef/zzz_generated/**/*"
- "examples/platform/nxp/k32w/k32w0/scripts/demo_generated_certs/**/*"
diff --git a/BUILD.gn b/BUILD.gn
index e4e1b8e02da1b5..23bc58926aac8d 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -120,7 +120,10 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
}
pw_python_pip_install("pip_install_matter_packages") {
- packages = [ "//examples/common/pigweed/rpc_console:chip_rpc_distribution" ]
+ packages = [
+ "//examples/common/pigweed/rpc_console:chip_rpc_distribution",
+ "//scripts:yamltests_distribution",
+ ]
}
# Python packages installed during bootstrap.
@@ -260,7 +263,8 @@ if (current_toolchain != "${dir_pw_toolchain}/default:default") {
"//:fake_platform_tests",
"//examples/chef:chef.tests",
"//scripts/build:build_examples.tests",
- "//scripts/idl:idl.tests",
+ "//scripts/py_matter_idl:matter_idl.tests",
+ "//scripts/py_matter_yamltests:matter_yamltests.tests",
"//src:tests_run",
]
}
diff --git a/build/chip/chip_codegen.gni b/build/chip/chip_codegen.gni
index 533cd02b27ea76..d59277ae1e484d 100644
--- a/build/chip/chip_codegen.gni
+++ b/build/chip/chip_codegen.gni
@@ -17,7 +17,7 @@ import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/python.gni")
-import("${chip_root}/scripts/idl/files.gni")
+import("${chip_root}/scripts/py_matter_idl/files.gni")
declare_args() {
# Location where code has been pre-generated
diff --git a/docs/code_generation.md b/docs/code_generation.md
index 7deed7ba05fb1a..c676fa887ebd7c 100644
--- a/docs/code_generation.md
+++ b/docs/code_generation.md
@@ -84,9 +84,10 @@ specific codegen.
### `*.matter` parsing and codegen
`*.matter` files are both human and machine readable. Code that can process
-these files is available at `scripts/idl` and `scripts/codegen.py`. You can read
-the [scripts/idl/README.md](../scripts/idl/README.md) for details of how things
-work.
+these files is available at `scripts/py_matter_idl` and `scripts/codegen.py`.
+You can read the
+[scripts/py_matter_idl/matter_idl/README.md](../scripts/py_matter_idl/matter_idl/README.md)
+for details of how things work.
`scripts/codegen.py` can generate various outputs based on an input `*.matter`
file.
@@ -198,7 +199,7 @@ Code pre-generation can be used:
generation at build time or to save the code generation time at the expense
of running code generation for every possible zap/generation type
- To check changes in generated code across versions, beyond the comparisons
- of golden image tests in `scripts/idl/tests`
+ of golden image tests in `scripts/py_matter_idl/matter_idl/tests`
The script to trigger code pre-generation is `scripts/code_pregenerate.py` and
requires the pre-generation output directory as an argument
diff --git a/scripts/BUILD.gn b/scripts/BUILD.gn
index 141e262d5db3e4..878102414b89ce 100644
--- a/scripts/BUILD.gn
+++ b/scripts/BUILD.gn
@@ -12,6 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import("//build_overrides/build.gni")
+import("//build_overrides/chip.gni")
+
import("//build_overrides/pigweed.gni")
+import("$dir_pw_build/python_dist.gni")
-import("$dir_pw_build/python.gni")
+# This target creates a single Python package and wheel for yamltests. It will
+# merge all Python dependencies Matter. The output is located in:
+# out/obj/yamltests_distribution/ <- source files here
+# out/obj/yamltests_distribution._build_wheel/yamltests-0.0.1-py3-none-any.whl
+pw_python_distribution("yamltests_distribution") {
+ packages = [ "${chip_root}/scripts/py_matter_yamltests:matter_yamltests" ]
+ generate_setup_cfg = {
+ common_config_file = "common_setup.cfg"
+ include_default_pyproject_file = true
+ append_date_to_version = true
+ }
+}
diff --git a/scripts/codegen.py b/scripts/codegen.py
index 67898af6ebce5f..5d824be7bfebf8 100755
--- a/scripts/codegen.py
+++ b/scripts/codegen.py
@@ -25,14 +25,14 @@
_has_coloredlogs = False
try:
- from idl.matter_idl_parser import CreateParser
+ from matter_idl.matter_idl_parser import CreateParser
except:
import os
- sys.path.append(os.path.abspath(os.path.dirname(__file__)))
- from idl.matter_idl_parser import CreateParser
+ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'py_matter_idl')))
+ from matter_idl.matter_idl_parser import CreateParser
-from idl.generators import FileSystemGeneratorStorage, GeneratorStorage
-from idl.generators.registry import CodeGenerator, GENERATORS
+from matter_idl.generators import FileSystemGeneratorStorage, GeneratorStorage
+from matter_idl.generators.registry import CodeGenerator, GENERATORS
class ListGeneratedFilesStorage(GeneratorStorage):
diff --git a/scripts/common_setup.cfg b/scripts/common_setup.cfg
new file mode 100644
index 00000000000000..76987454de4736
--- /dev/null
+++ b/scripts/common_setup.cfg
@@ -0,0 +1,19 @@
+# Copyright (c) 2022 Project CHIP Authors
+#
+# 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.
+[metadata]
+name = matter_yamltests
+version = 0.0.1
+
+[options]
+zip_safe = False
diff --git a/scripts/idl/BUILD.gn b/scripts/idl/BUILD.gn
deleted file mode 100644
index 324ed3a737bbf0..00000000000000
--- a/scripts/idl/BUILD.gn
+++ /dev/null
@@ -1,79 +0,0 @@
-# Copyright (c) 2022 Project CHIP Authors
-#
-# 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("//build_overrides/build.gni")
-import("//build_overrides/chip.gni")
-
-import("//build_overrides/pigweed.gni")
-import("$dir_pw_build/python.gni")
-
-import("${chip_root}/scripts/idl/files.gni")
-
-pw_python_package("idl") {
- setup = [ "setup.py" ]
- inputs = matter_idl_generator_templates
- inputs += [
- # Dependency grammar
- "matter_grammar.lark",
-
- # Unit test data
- "tests/available_tests.yaml",
- "tests/inputs/cluster_struct_attribute.matter",
- "tests/inputs/global_struct_attribute.matter",
- "tests/inputs/optional_argument.matter",
- "tests/inputs/several_clusters.matter",
- "tests/inputs/simple_attribute.matter",
- "tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h",
- "tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h",
- "tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h",
- "tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp",
- "tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp",
- "tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h",
- "tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h",
- "tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h",
- "tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp",
- "tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp",
- "tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp",
- "tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp",
- "tests/outputs/several_clusters/bridge/BridgeClustersImpl.h",
- "tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h",
- "tests/outputs/several_clusters/bridge/FirstServer.h",
- "tests/outputs/several_clusters/bridge/SecondServer.h",
- "tests/outputs/several_clusters/bridge/Third.h",
- "tests/outputs/several_clusters/bridge/ThirdServer.h",
- "tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp",
- "tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp",
- "tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp",
- "tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp",
- "tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp",
- "tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp",
- "tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h",
- "tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h",
- "tests/outputs/simple_attribute/bridge/MyClusterServer.h",
- "tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp",
- "tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp",
- ]
-
- sources = matter_idl_generator_sources
-
- tests = [
- "test_matter_idl_parser.py",
- "test_generators.py",
- "test_xml_parser.py",
- ]
-
- # TODO: at a future time consider enabling all (* or missing) here to get
- # pylint checking these files
- static_analysis = []
-}
diff --git a/scripts/idl/files.gni b/scripts/idl/files.gni
deleted file mode 100644
index 997f1eab8b06c5..00000000000000
--- a/scripts/idl/files.gni
+++ /dev/null
@@ -1,37 +0,0 @@
-import("//build_overrides/build.gni")
-import("//build_overrides/chip.gni")
-
-# Templates used for generation
-matter_idl_generator_templates = [
- "${chip_root}/scripts/idl/generators/bridge/BridgeClustersCpp.jinja",
- "${chip_root}/scripts/idl/generators/bridge/BridgeClustersCommon.jinja",
- "${chip_root}/scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja",
- "${chip_root}/scripts/idl/generators/java/ChipClustersCpp.jinja",
- "${chip_root}/scripts/idl/generators/java/ChipClustersRead.jinja",
- "${chip_root}/scripts/idl/generators/cpp/application/CallbackStubSource.jinja",
- "${chip_root}/scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja",
-]
-
-matter_idl_generator_sources = [
- "${chip_root}/scripts/idl/__init__.py",
- "${chip_root}/scripts/idl/generators/__init__.py",
- "${chip_root}/scripts/idl/generators/bridge/__init__.py",
- "${chip_root}/scripts/idl/generators/cpp/__init__.py",
- "${chip_root}/scripts/idl/generators/cpp/application/__init__.py",
- "${chip_root}/scripts/idl/generators/filters.py",
- "${chip_root}/scripts/idl/generators/java/__init__.py",
- "${chip_root}/scripts/idl/generators/types.py",
- "${chip_root}/scripts/idl/matter_idl_parser.py",
- "${chip_root}/scripts/idl/matter_idl_types.py",
- "${chip_root}/scripts/idl/xml_parser.py",
- "${chip_root}/scripts/idl/zapxml/__init__.py",
- "${chip_root}/scripts/idl/zapxml/handlers/__init__.py",
- "${chip_root}/scripts/idl/zapxml/handlers/base.py",
- "${chip_root}/scripts/idl/zapxml/handlers/context.py",
- "${chip_root}/scripts/idl/zapxml/handlers/handlers.py",
- "${chip_root}/scripts/idl/zapxml/handlers/parsing.py",
-]
-
-# All the files that the matter idl infrastructure will use
-matter_idl_generator_files =
- matter_idl_generator_templates + matter_idl_generator_sources
diff --git a/scripts/idl_lint.py b/scripts/idl_lint.py
index 83f606201f8bac..a9271afbd73fc0 100755
--- a/scripts/idl_lint.py
+++ b/scripts/idl_lint.py
@@ -23,12 +23,12 @@
from typing import List, Optional
try:
- from idl import matter_idl_parser
+ from matter_idl import matter_idl_parser
except:
- sys.path.append(os.path.abspath(os.path.dirname(__file__)))
- from idl import matter_idl_parser
+ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), 'py_matter_idl')))
+ from matter_idl import matter_idl_parser
-import idl.lint
+import matter_idl.lint
# Supported log levels, mapping string values required for argument
# parsing into logging constants
@@ -64,7 +64,7 @@ def main(log_level, rules, idl_path):
lint_rules = []
logging.info("Loading rules from %s" % rules)
- lint_rules.extend(idl.lint.CreateParser(rules).parse())
+ lint_rules.extend(matter_idl.lint.CreateParser(rules).parse())
logging.info("Parsing idl from %s" % idl_path)
idl_tree = matter_idl_parser.CreateParser().parse(open(idl_path, "rt").read(), file_name=idl_path)
diff --git a/scripts/py_matter_idl/BUILD.gn b/scripts/py_matter_idl/BUILD.gn
new file mode 100644
index 00000000000000..7e3254573e9cac
--- /dev/null
+++ b/scripts/py_matter_idl/BUILD.gn
@@ -0,0 +1,83 @@
+# Copyright (c) 2022 Project CHIP Authors
+#
+# 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("//build_overrides/build.gni")
+import("//build_overrides/chip.gni")
+
+import("//build_overrides/pigweed.gni")
+import("$dir_pw_build/python.gni")
+
+import("${chip_root}/scripts/py_matter_idl/files.gni")
+
+pw_python_package("matter_idl") {
+ setup = [
+ "setup.py",
+ "setup.cfg",
+ "pyproject.toml",
+ ]
+ inputs = matter_idl_generator_templates
+ inputs += [
+ # Dependency grammar
+ "matter_idl/matter_grammar.lark",
+
+ # Unit test data
+ "matter_idl/tests/available_tests.yaml",
+ "matter_idl/tests/inputs/cluster_struct_attribute.matter",
+ "matter_idl/tests/inputs/global_struct_attribute.matter",
+ "matter_idl/tests/inputs/optional_argument.matter",
+ "matter_idl/tests/inputs/several_clusters.matter",
+ "matter_idl/tests/inputs/simple_attribute.matter",
+ "matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h",
+ "matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h",
+ "matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h",
+ "matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp",
+ "matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp",
+ "matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h",
+ "matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h",
+ "matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h",
+ "matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp",
+ "matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp",
+ "matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp",
+ "matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp",
+ "matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h",
+ "matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h",
+ "matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h",
+ "matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h",
+ "matter_idl/tests/outputs/several_clusters/bridge/Third.h",
+ "matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h",
+ "matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp",
+ "matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp",
+ "matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp",
+ "matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp",
+ "matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp",
+ "matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp",
+ "matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h",
+ "matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h",
+ "matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h",
+ "matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp",
+ "matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp",
+ ]
+
+ sources = matter_idl_generator_sources
+
+ tests = [
+ "matter_idl/test_matter_idl_parser.py",
+ "matter_idl/test_generators.py",
+ "matter_idl/test_xml_parser.py",
+ ]
+
+ # TODO: at a future time consider enabling all (* or missing) here to get
+ # pylint checking these files
+ static_analysis = []
+}
diff --git a/scripts/py_matter_idl/files.gni b/scripts/py_matter_idl/files.gni
new file mode 100644
index 00000000000000..aa22f705caff2d
--- /dev/null
+++ b/scripts/py_matter_idl/files.gni
@@ -0,0 +1,37 @@
+import("//build_overrides/build.gni")
+import("//build_overrides/chip.gni")
+
+# Templates used for generation
+matter_idl_generator_templates = [
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja",
+]
+
+matter_idl_generator_sources = [
+ "${chip_root}/scripts/py_matter_idl/matter_idl/__init__.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/__init__.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/filters.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/java/__init__.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/generators/types.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/matter_idl_parser.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/matter_idl_types.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/xml_parser.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/__init__.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py",
+ "${chip_root}/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py",
+]
+
+# All the files that the matter idl infrastructure will use
+matter_idl_generator_files =
+ matter_idl_generator_templates + matter_idl_generator_sources
diff --git a/scripts/idl/README.md b/scripts/py_matter_idl/matter_idl/README.md
similarity index 99%
rename from scripts/idl/README.md
rename to scripts/py_matter_idl/matter_idl/README.md
index ac3ddf517f8277..e46fb4d00c853a 100644
--- a/scripts/idl/README.md
+++ b/scripts/py_matter_idl/matter_idl/README.md
@@ -184,7 +184,7 @@ endpoint 0 {
## Parsing of IDLs
-IDL parsing is done within the `idl` python package (this is the current
+IDL parsing is done within the `matter_idl` python package (this is the current
directory of this README). Most of the heavy lifting is done by the lark using
[matter_grammar.lark](./matter_grammar.lark), which is then turned into an AST:
diff --git a/scripts/idl/__init__.py b/scripts/py_matter_idl/matter_idl/__init__.py
similarity index 100%
rename from scripts/idl/__init__.py
rename to scripts/py_matter_idl/matter_idl/__init__.py
diff --git a/scripts/idl/generators/__init__.py b/scripts/py_matter_idl/matter_idl/generators/__init__.py
similarity index 97%
rename from scripts/idl/generators/__init__.py
rename to scripts/py_matter_idl/matter_idl/generators/__init__.py
index 1adbb6d4d0071b..779c5ad800ace2 100644
--- a/scripts/idl/generators/__init__.py
+++ b/scripts/py_matter_idl/matter_idl/generators/__init__.py
@@ -18,7 +18,7 @@
import jinja2
from typing import Dict
-from idl.matter_idl_types import Idl
+from matter_idl.matter_idl_types import Idl
from .filters import RegisterCommonFilters
@@ -113,7 +113,8 @@ def __init__(self, storage: GeneratorStorage, idl: Idl):
self.storage = storage
self.idl = idl
self.jinja_env = jinja2.Environment(
- loader=jinja2.FileSystemLoader(searchpath=os.path.dirname(__file__)),
+ loader=jinja2.FileSystemLoader(
+ searchpath=os.path.dirname(__file__)),
keep_trailing_newline=True)
self.dry_run = False
diff --git a/scripts/idl/generators/bridge/BridgeClustersCommon.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja
similarity index 100%
rename from scripts/idl/generators/bridge/BridgeClustersCommon.jinja
rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCommon.jinja
diff --git a/scripts/idl/generators/bridge/BridgeClustersCpp.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja
similarity index 100%
rename from scripts/idl/generators/bridge/BridgeClustersCpp.jinja
rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersCpp.jinja
diff --git a/scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja
similarity index 100%
rename from scripts/idl/generators/bridge/BridgeClustersGlobalStructs.jinja
rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersGlobalStructs.jinja
diff --git a/scripts/idl/generators/bridge/BridgeClustersHeader.jinja b/scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersHeader.jinja
similarity index 100%
rename from scripts/idl/generators/bridge/BridgeClustersHeader.jinja
rename to scripts/py_matter_idl/matter_idl/generators/bridge/BridgeClustersHeader.jinja
diff --git a/scripts/idl/generators/bridge/__init__.py b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py
similarity index 91%
rename from scripts/idl/generators/bridge/__init__.py
rename to scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py
index 7a43c9e802b88a..149e6cf33e1d04 100644
--- a/scripts/idl/generators/bridge/__init__.py
+++ b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py
@@ -17,11 +17,11 @@
import logging
import re
-from idl.generators import CodeGenerator, GeneratorStorage
-from idl.matter_idl_types import Idl, Field, Attribute, Cluster, ClusterSide
-from idl import matter_idl_types
-from idl.generators.types import (ParseDataType, BasicString, BasicInteger, FundamentalType,
- IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext)
+from matter_idl.generators import CodeGenerator, GeneratorStorage
+from matter_idl.matter_idl_types import Idl, Field, Attribute, Cluster, ClusterSide
+from matter_idl import matter_idl_types
+from matter_idl.generators.types import (ParseDataType, BasicString, BasicInteger, FundamentalType,
+ IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext)
from typing import Union, List, Set
@@ -74,14 +74,16 @@ def get_field_info(definition: Field, cluster: Cluster, idl: Idl):
def get_raw_size_and_type(attr: Attribute, cluster: Cluster, idl: Idl):
- container, cType, size, matterType = get_field_info(attr.definition, cluster, idl)
+ container, cType, size, matterType = get_field_info(
+ attr.definition, cluster, idl)
if attr.definition.is_list:
return 'ZCL_ARRAY_ATTRIBUTE_TYPE, {}'.format(size)
return '{}, {}'.format(matterType, size)
def get_field_type(definition: Field, cluster: Cluster, idl: Idl):
- container, cType, size, matterType = get_field_info(definition, cluster, idl)
+ container, cType, size, matterType = get_field_info(
+ definition, cluster, idl)
if container == 'OctetString':
return 'std::string'
if definition.is_list:
diff --git a/scripts/idl/generators/cpp/__init__.py b/scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py
similarity index 100%
rename from scripts/idl/generators/cpp/__init__.py
rename to scripts/py_matter_idl/matter_idl/generators/cpp/__init__.py
diff --git a/scripts/idl/generators/cpp/application/CallbackStubSource.jinja b/scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja
similarity index 100%
rename from scripts/idl/generators/cpp/application/CallbackStubSource.jinja
rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/CallbackStubSource.jinja
diff --git a/scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja b/scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja
similarity index 100%
rename from scripts/idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja
rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/PluginApplicationCallbacksHeader.jinja
diff --git a/scripts/idl/generators/cpp/application/__init__.py b/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py
similarity index 84%
rename from scripts/idl/generators/cpp/application/__init__.py
rename to scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py
index 4a7a3b0035ce75..ead462b2c33cb0 100644
--- a/scripts/idl/generators/cpp/application/__init__.py
+++ b/scripts/py_matter_idl/matter_idl/generators/cpp/application/__init__.py
@@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from idl.generators import CodeGenerator, GeneratorStorage
-from idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType
-from idl import matter_idl_types
-from idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext
+from matter_idl.generators import CodeGenerator, GeneratorStorage
+from matter_idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType
+from matter_idl import matter_idl_types
+from matter_idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext
from typing import Union, List, Set
from stringcase import capitalcase
diff --git a/scripts/idl/generators/filters.py b/scripts/py_matter_idl/matter_idl/generators/filters.py
similarity index 100%
rename from scripts/idl/generators/filters.py
rename to scripts/py_matter_idl/matter_idl/generators/filters.py
diff --git a/scripts/idl/generators/java/ChipClustersCpp.jinja b/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja
similarity index 100%
rename from scripts/idl/generators/java/ChipClustersCpp.jinja
rename to scripts/py_matter_idl/matter_idl/generators/java/ChipClustersCpp.jinja
diff --git a/scripts/idl/generators/java/ChipClustersRead.jinja b/scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja
similarity index 100%
rename from scripts/idl/generators/java/ChipClustersRead.jinja
rename to scripts/py_matter_idl/matter_idl/generators/java/ChipClustersRead.jinja
diff --git a/scripts/idl/generators/java/__init__.py b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py
similarity index 97%
rename from scripts/idl/generators/java/__init__.py
rename to scripts/py_matter_idl/matter_idl/generators/java/__init__.py
index 6f18e9629304e5..a0f465b4e2f416 100644
--- a/scripts/idl/generators/java/__init__.py
+++ b/scripts/py_matter_idl/matter_idl/generators/java/__init__.py
@@ -13,10 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from idl.generators import CodeGenerator, GeneratorStorage
-from idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType
-from idl import matter_idl_types
-from idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext
+from matter_idl.generators import CodeGenerator, GeneratorStorage
+from matter_idl.matter_idl_types import Idl, ClusterSide, Field, Attribute, Cluster, FieldQuality, Command, DataType
+from matter_idl import matter_idl_types
+from matter_idl.generators.types import ParseDataType, BasicString, BasicInteger, FundamentalType, IdlType, IdlEnumType, IdlBitmapType, TypeLookupContext
from typing import Union, List, Set
from stringcase import capitalcase
diff --git a/scripts/idl/generators/registry.py b/scripts/py_matter_idl/matter_idl/generators/registry.py
similarity index 90%
rename from scripts/idl/generators/registry.py
rename to scripts/py_matter_idl/matter_idl/generators/registry.py
index 8feeb2c48d1124..5510d3976dc623 100644
--- a/scripts/idl/generators/registry.py
+++ b/scripts/py_matter_idl/matter_idl/generators/registry.py
@@ -14,9 +14,9 @@
import enum
-from idl.generators.java import JavaGenerator
-from idl.generators.bridge import BridgeGenerator
-from idl.generators.cpp.application import CppApplicationGenerator
+from matter_idl.generators.java import JavaGenerator
+from matter_idl.generators.bridge import BridgeGenerator
+from matter_idl.generators.cpp.application import CppApplicationGenerator
class CodeGenerator(enum.Enum):
diff --git a/scripts/idl/generators/types.py b/scripts/py_matter_idl/matter_idl/generators/types.py
similarity index 99%
rename from scripts/idl/generators/types.py
rename to scripts/py_matter_idl/matter_idl/generators/types.py
index b6f216802de0d8..dd7705dc7070f9 100644
--- a/scripts/idl/generators/types.py
+++ b/scripts/py_matter_idl/matter_idl/generators/types.py
@@ -15,8 +15,8 @@
import logging
import enum
-from idl.matter_idl_types import DataType
-from idl import matter_idl_types # to explicitly say 'Enum'
+from matter_idl.matter_idl_types import DataType
+from matter_idl import matter_idl_types # to explicitly say 'Enum'
from typing import Union, List, Optional
from dataclasses import dataclass
diff --git a/scripts/idl/lint/__init__.py b/scripts/py_matter_idl/matter_idl/lint/__init__.py
similarity index 100%
rename from scripts/idl/lint/__init__.py
rename to scripts/py_matter_idl/matter_idl/lint/__init__.py
diff --git a/scripts/idl/lint/lint_rules_grammar.lark b/scripts/py_matter_idl/matter_idl/lint/lint_rules_grammar.lark
similarity index 100%
rename from scripts/idl/lint/lint_rules_grammar.lark
rename to scripts/py_matter_idl/matter_idl/lint/lint_rules_grammar.lark
diff --git a/scripts/idl/lint/lint_rules_parser.py b/scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py
similarity index 91%
rename from scripts/idl/lint/lint_rules_parser.py
rename to scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py
index fdd507cdbc383e..18bbb473b7871c 100755
--- a/scripts/idl/lint/lint_rules_parser.py
+++ b/scripts/py_matter_idl/matter_idl/lint/lint_rules_parser.py
@@ -16,8 +16,9 @@
except:
import sys
- sys.path.append(os.path.join(os.path.abspath(os.path.dirname(__file__)), "..", ".."))
- from idl.lint.types import RequiredAttributesRule, AttributeRequirement, ClusterRequirement, RequiredCommandsRule, ClusterCommandRequirement
+ sys.path.append(os.path.join(os.path.abspath(
+ os.path.dirname(__file__)), "..", ".."))
+ from matter_idl.lint.types import RequiredAttributesRule, AttributeRequirement, ClusterRequirement, RequiredCommandsRule, ClusterCommandRequirement
def parseNumberString(n):
@@ -90,7 +91,8 @@ def DecodeClusterFromXml(element: xml.etree.ElementTree.Element):
if 'optional' in cmd.attrib and cmd.attrib['optional'] == 'true':
continue
- required_commands.append(RequiredCommand(name=cmd.attrib["name"], code=parseNumberString(cmd.attrib['code'])))
+ required_commands.append(RequiredCommand(
+ name=cmd.attrib["name"], code=parseNumberString(cmd.attrib['code'])))
return DecodedCluster(
name=name,
@@ -124,8 +126,10 @@ class LintRulesContext:
"""
def __init__(self):
- self._required_attributes_rule = RequiredAttributesRule("Required attributes")
- self._required_commands_rule = RequiredCommandsRule("Required commands")
+ self._required_attributes_rule = RequiredAttributesRule(
+ "Required attributes")
+ self._required_commands_rule = RequiredCommandsRule(
+ "Required commands")
# Map cluster names to the underlying code
self._cluster_codes: Mapping[str, int] = {}
@@ -146,7 +150,8 @@ def RequireClusterInEndpoint(self, name: str, code: int):
name = "ID_%s" % name
except ValueError:
logging.error("UNKNOWN cluster name %s" % name)
- logging.error("Known names: %s" % (",".join(self._cluster_codes.keys()), ))
+ logging.error("Known names: %s" %
+ (",".join(self._cluster_codes.keys()), ))
return
else:
cluster_code = self._cluster_codes[name]
@@ -237,7 +242,8 @@ def all_endpoint_rule(self, attributes):
@v_args(inline=True)
def load_xml(self, path):
if not os.path.isabs(path):
- path = os.path.abspath(os.path.join(os.path.dirname(self.file_name), path))
+ path = os.path.abspath(os.path.join(
+ os.path.dirname(self.file_name), path))
self.context.LoadXml(path)
@@ -262,7 +268,8 @@ def __init__(self, parser, file_name: str):
self.file_name = file_name
def parse(self):
- data = LintRulesTransformer(self.file_name).transform(self.parser.parse(open(self.file_name, "rt").read()))
+ data = LintRulesTransformer(self.file_name).transform(
+ self.parser.parse(open(self.file_name, "rt").read()))
return data
diff --git a/scripts/idl/lint/types.py b/scripts/py_matter_idl/matter_idl/lint/types.py
similarity index 92%
rename from scripts/idl/lint/types.py
rename to scripts/py_matter_idl/matter_idl/lint/types.py
index 85dfbdeacd0bc3..8ee6a805ec4d4e 100644
--- a/scripts/idl/lint/types.py
+++ b/scripts/py_matter_idl/matter_idl/lint/types.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from idl.matter_idl_types import Idl, ParseMetaData, ClusterSide
+from matter_idl.matter_idl_types import Idl, ParseMetaData, ClusterSide
from abc import ABC, abstractmethod
from typing import List, Optional
from dataclasses import dataclass, field
@@ -40,7 +40,8 @@ class LintError:
def __init__(self, text: str, location: Optional[LocationInFile] = None):
self.message = text
if location:
- self.message += " at %s:%d:%d" % (location.file_name, location.line, location.column)
+ self.message += " at %s:%d:%d" % (location.file_name,
+ location.line, location.column)
def __str__(self):
return self.message
@@ -84,7 +85,8 @@ def __init__(self, name):
self._idl = None
def _AddLintError(self, text, location):
- self._lint_errors.append(LintError("%s: %s" % (self.name, text), location))
+ self._lint_errors.append(
+ LintError("%s: %s" % (self.name, text), location))
def _ParseLocation(self, meta: Optional[ParseMetaData]) -> Optional[LocationInFile]:
"""Create a location in the current file that is being parsed. """
@@ -146,11 +148,13 @@ def _ServerClusterDefinition(self, name: str, location: Optional[LocationInFile]
c for c in self._idl.clusters if c.name == name and c.side == ClusterSide.SERVER
]
if not cluster_definition:
- self._AddLintError("Cluster definition for %s not found" % cluster.name, location)
+ self._AddLintError(
+ "Cluster definition for %s not found" % cluster.name, location)
return None
if len(cluster_definition) > 1:
- self._AddLintError("Multiple cluster definitions found for %s" % cluster.name, location)
+ self._AddLintError(
+ "Multiple cluster definitions found for %s" % cluster.name, location)
return None
return cluster_definition[0]
@@ -161,7 +165,8 @@ def _LintImpl(self):
cluster_codes = set()
for cluster in endpoint.server_clusters:
- cluster_definition = self._ServerClusterDefinition(cluster.name, self._ParseLocation(cluster.parse_meta))
+ cluster_definition = self._ServerClusterDefinition(
+ cluster.name, self._ParseLocation(cluster.parse_meta))
if not cluster_definition:
continue
@@ -215,7 +220,8 @@ def __init__(self, name):
super(RequiredCommandsRule, self).__init__(name)
# Maps cluster id to mandatory cluster requirement
- self._mandatory_commands: Maping[int, List[ClusterCommandRequirement]] = {}
+ self._mandatory_commands: Maping[int,
+ List[ClusterCommandRequirement]] = {}
def __repr__(self):
result = "RequiredCommandsRule{\n"
diff --git a/scripts/idl/matter_grammar.lark b/scripts/py_matter_idl/matter_idl/matter_grammar.lark
similarity index 100%
rename from scripts/idl/matter_grammar.lark
rename to scripts/py_matter_idl/matter_idl/matter_grammar.lark
diff --git a/scripts/idl/matter_idl_parser.py b/scripts/py_matter_idl/matter_idl/matter_idl_parser.py
similarity index 100%
rename from scripts/idl/matter_idl_parser.py
rename to scripts/py_matter_idl/matter_idl/matter_idl_parser.py
diff --git a/scripts/idl/matter_idl_types.py b/scripts/py_matter_idl/matter_idl/matter_idl_types.py
similarity index 100%
rename from scripts/idl/matter_idl_types.py
rename to scripts/py_matter_idl/matter_idl/matter_idl_types.py
diff --git a/scripts/idl/test_generators.py b/scripts/py_matter_idl/matter_idl/test_generators.py
similarity index 93%
rename from scripts/idl/test_generators.py
rename to scripts/py_matter_idl/matter_idl/test_generators.py
index 730bfdbc610762..9fb21aecf565dd 100755
--- a/scripts/idl/test_generators.py
+++ b/scripts/py_matter_idl/matter_idl/test_generators.py
@@ -22,19 +22,19 @@
from dataclasses import dataclass, field
try:
- from idl.matter_idl_parser import CreateParser
+ from matter_idl.matter_idl_parser import CreateParser
except:
import sys
sys.path.append(os.path.abspath(
os.path.join(os.path.dirname(__file__), '..')))
- from idl.matter_idl_parser import CreateParser
+ from matter_idl.matter_idl_parser import CreateParser
-from idl.matter_idl_types import Idl
-from idl.generators.java import JavaGenerator
-from idl.generators.bridge import BridgeGenerator
-from idl.generators.cpp.application import CppApplicationGenerator
-from idl.generators import GeneratorStorage
+from matter_idl.matter_idl_types import Idl
+from matter_idl.generators.java import JavaGenerator
+from matter_idl.generators.bridge import BridgeGenerator
+from matter_idl.generators.cpp.application import CppApplicationGenerator
+from matter_idl.generators import GeneratorStorage
TESTS_DIR = os.path.join(os.path.dirname(__file__), "tests")
diff --git a/scripts/idl/test_matter_idl_parser.py b/scripts/py_matter_idl/matter_idl/test_matter_idl_parser.py
similarity index 100%
rename from scripts/idl/test_matter_idl_parser.py
rename to scripts/py_matter_idl/matter_idl/test_matter_idl_parser.py
diff --git a/scripts/idl/test_xml_parser.py b/scripts/py_matter_idl/matter_idl/test_xml_parser.py
similarity index 90%
rename from scripts/idl/test_xml_parser.py
rename to scripts/py_matter_idl/matter_idl/test_xml_parser.py
index 932a5731d59268..e8645cb0f4043d 100755
--- a/scripts/idl/test_xml_parser.py
+++ b/scripts/py_matter_idl/matter_idl/test_xml_parser.py
@@ -19,16 +19,17 @@
from typing import Optional, Union, List
try:
- from idl.matter_idl_types import *
- from idl.zapxml import ParseSource, ParseXmls
+ from matter_idl.matter_idl_types import *
+ from matter_idl.zapxml import ParseSource, ParseXmls
except:
import os
import sys
- sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
+ sys.path.append(os.path.abspath(
+ os.path.join(os.path.dirname(__file__), '..')))
- from idl.matter_idl_types import *
- from idl.zapxml import ParseSource, ParseXmls
+ from matter_idl.matter_idl_types import *
+ from matter_idl.zapxml import ParseSource, ParseXmls
def XmlToIdl(what: Union[str, List[str]]) -> Idl:
@@ -37,7 +38,8 @@ def XmlToIdl(what: Union[str, List[str]]) -> Idl:
sources = []
for idx, txt in enumerate(what):
- sources.append(ParseSource(source=io.StringIO(txt), name=("Input %d" % (idx + 1))))
+ sources.append(ParseSource(source=io.StringIO(
+ txt), name=("Input %d" % (idx + 1))))
return ParseXmls(sources, include_meta_data=False)
@@ -97,8 +99,10 @@ def testCluster(self):
structs=[
Struct(name='GetSomeDataRequest',
fields=[
- Field(data_type=DataType(name='INT8U'), code=0, name='firstInput'),
- Field(data_type=DataType(name='INT16U'), code=1, name='secondInput')
+ Field(data_type=DataType(
+ name='INT8U'), code=0, name='firstInput'),
+ Field(data_type=DataType(
+ name='INT16U'), code=1, name='secondInput')
],
tag=StructTag.REQUEST),
Struct(name='GetSomeDataResponse',
@@ -142,8 +146,10 @@ def testBitmap(self):
self.assertEqual(idl,
Idl(clusters=[
- Cluster(side=ClusterSide.CLIENT, name='Test1', code=1, bitmaps=[bitmap]),
- Cluster(side=ClusterSide.CLIENT, name='Test2', code=2, bitmaps=[bitmap]),
+ Cluster(side=ClusterSide.CLIENT,
+ name='Test1', code=1, bitmaps=[bitmap]),
+ Cluster(side=ClusterSide.CLIENT,
+ name='Test2', code=2, bitmaps=[bitmap]),
]))
def testFabricScopedAndSensitive(self):
@@ -226,19 +232,23 @@ def testStruct(self):
name='SomeStruct',
qualities=StructQuality.FABRIC_SCOPED,
fields=[
- Field(data_type=DataType(name='int16u'), code=0, name='FirstMember'),
- Field(data_type=DataType(name='int32u'), code=1, name='SecondMember')
+ Field(data_type=DataType(name='int16u'),
+ code=0, name='FirstMember'),
+ Field(data_type=DataType(name='int32u'),
+ code=1, name='SecondMember')
]
)
self.assertEqual(idl,
Idl(clusters=[
- Cluster(side=ClusterSide.CLIENT, name='Test1', code=10, structs=[struct]),
+ Cluster(side=ClusterSide.CLIENT,
+ name='Test1', code=10, structs=[struct]),
Cluster(side=ClusterSide.CLIENT, name='Test2', code=20,
structs=[struct],
attributes=[
Attribute(
definition=Field(
- data_type=DataType(name='SomeStruct'),
+ data_type=DataType(
+ name='SomeStruct'),
code=123,
name='FabricAttribute',
qualities=FieldQuality.NULLABLE
@@ -287,7 +297,8 @@ def testSkipsNotProcessedFields(self):
attributes=[
Attribute(
definition=Field(
- data_type=DataType(name='Type'),
+ data_type=DataType(
+ name='Type'),
code=0,
name='Type',
),
diff --git a/scripts/idl/tests/available_tests.yaml b/scripts/py_matter_idl/matter_idl/tests/available_tests.yaml
similarity index 100%
rename from scripts/idl/tests/available_tests.yaml
rename to scripts/py_matter_idl/matter_idl/tests/available_tests.yaml
diff --git a/scripts/idl/tests/inputs/cluster_struct_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter
similarity index 100%
rename from scripts/idl/tests/inputs/cluster_struct_attribute.matter
rename to scripts/py_matter_idl/matter_idl/tests/inputs/cluster_struct_attribute.matter
diff --git a/scripts/idl/tests/inputs/global_struct_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter
similarity index 100%
rename from scripts/idl/tests/inputs/global_struct_attribute.matter
rename to scripts/py_matter_idl/matter_idl/tests/inputs/global_struct_attribute.matter
diff --git a/scripts/idl/tests/inputs/large_all_clusters_app.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter
similarity index 100%
rename from scripts/idl/tests/inputs/large_all_clusters_app.matter
rename to scripts/py_matter_idl/matter_idl/tests/inputs/large_all_clusters_app.matter
diff --git a/scripts/idl/tests/inputs/large_lighting_app.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter
similarity index 100%
rename from scripts/idl/tests/inputs/large_lighting_app.matter
rename to scripts/py_matter_idl/matter_idl/tests/inputs/large_lighting_app.matter
diff --git a/scripts/idl/tests/inputs/optional_argument.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter
similarity index 100%
rename from scripts/idl/tests/inputs/optional_argument.matter
rename to scripts/py_matter_idl/matter_idl/tests/inputs/optional_argument.matter
diff --git a/scripts/idl/tests/inputs/several_clusters.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter
similarity index 100%
rename from scripts/idl/tests/inputs/several_clusters.matter
rename to scripts/py_matter_idl/matter_idl/tests/inputs/several_clusters.matter
diff --git a/scripts/idl/tests/inputs/simple_attribute.matter b/scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter
similarity index 100%
rename from scripts/idl/tests/inputs/simple_attribute.matter
rename to scripts/py_matter_idl/matter_idl/tests/inputs/simple_attribute.matter
diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h
similarity index 100%
rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeClustersImpl.h
diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h
similarity index 100%
rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/BridgeGlobalStructs.h
diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h
similarity index 100%
rename from scripts/idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/bridge/DemoClusterServer.h
diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp
diff --git a/scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/cluster_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp
diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h
similarity index 100%
rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeClustersImpl.h
diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h
similarity index 100%
rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/BridgeGlobalStructs.h
diff --git a/scripts/idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h
similarity index 100%
rename from scripts/idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/bridge/DemoClusterServer.h
diff --git a/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-InvokeSubscribeImpl.cpp
diff --git a/scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/global_struct_attribute/jni/DemoClusterClient-ReadImpl.cpp
diff --git a/scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h
similarity index 100%
rename from scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/PluginApplicationCallbacks.h
diff --git a/scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_all_clusters_app/cpp-app/callback-stub.cpp
diff --git a/scripts/idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h
similarity index 100%
rename from scripts/idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/PluginApplicationCallbacks.h
diff --git a/scripts/idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/large_lighting_app/cpp-app/callback-stub.cpp
diff --git a/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-InvokeSubscribeImpl.cpp
diff --git a/scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/optional_argument/jni/MyClusterClient-ReadImpl.cpp
diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeClustersImpl.h
diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/BridgeGlobalStructs.h
diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/FirstServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/bridge/FirstServer.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/FirstServer.h
diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/SecondServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/bridge/SecondServer.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/SecondServer.h
diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/Third.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/Third.h
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/bridge/Third.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/Third.h
diff --git a/scripts/idl/tests/outputs/several_clusters/bridge/ThirdServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/bridge/ThirdServer.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/bridge/ThirdServer.h
diff --git a/scripts/idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/PluginApplicationCallbacks.h
diff --git a/scripts/idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/cpp-app/callback-stub.cpp
diff --git a/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-InvokeSubscribeImpl.cpp
diff --git a/scripts/idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/FirstClient-ReadImpl.cpp
diff --git a/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-InvokeSubscribeImpl.cpp
diff --git a/scripts/idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/SecondClient-ReadImpl.cpp
diff --git a/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-InvokeSubscribeImpl.cpp
diff --git a/scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/jni/ThirdClient-ReadImpl.cpp
diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h
similarity index 100%
rename from scripts/idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeClustersImpl.h
diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h
similarity index 100%
rename from scripts/idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/BridgeGlobalStructs.h
diff --git a/scripts/idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h
similarity index 100%
rename from scripts/idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h
rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/bridge/MyClusterServer.h
diff --git a/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-InvokeSubscribeImpl.cpp
diff --git a/scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp b/scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp
similarity index 100%
rename from scripts/idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp
rename to scripts/py_matter_idl/matter_idl/tests/outputs/simple_attribute/jni/MyClusterClient-ReadImpl.cpp
diff --git a/scripts/idl/xml_parser.py b/scripts/py_matter_idl/matter_idl/xml_parser.py
similarity index 93%
rename from scripts/idl/xml_parser.py
rename to scripts/py_matter_idl/matter_idl/xml_parser.py
index f2955c973ef632..5ef145ee377462 100755
--- a/scripts/idl/xml_parser.py
+++ b/scripts/py_matter_idl/matter_idl/xml_parser.py
@@ -21,15 +21,15 @@
import xml.sax.handler
try:
- from idl.matter_idl_types import Idl
+ from matter_idl.matter_idl_types import Idl
except:
import sys
sys.path.append(os.path.abspath(
os.path.join(os.path.dirname(__file__), '..')))
- from idl.matter_idl_types import Idl
+ from matter_idl.matter_idl_types import Idl
-from idl.zapxml import ParseSource, ParseXmls
+from matter_idl.zapxml import ParseSource, ParseXmls
if __name__ == '__main__':
diff --git a/scripts/idl/zapxml/__init__.py b/scripts/py_matter_idl/matter_idl/zapxml/__init__.py
similarity index 90%
rename from scripts/idl/zapxml/__init__.py
rename to scripts/py_matter_idl/matter_idl/zapxml/__init__.py
index 332d1c244bea3b..41b31b452ae066 100644
--- a/scripts/idl/zapxml/__init__.py
+++ b/scripts/py_matter_idl/matter_idl/zapxml/__init__.py
@@ -19,8 +19,8 @@
from dataclasses import dataclass
from typing import Optional, Union, List
-from idl.zapxml.handlers import Context, ZapXmlHandler
-from idl.matter_idl_types import Idl
+from matter_idl.zapxml.handlers import Context, ZapXmlHandler
+from matter_idl.matter_idl_types import Idl
class ParseHandler(xml.sax.handler.ContentHandler):
@@ -32,7 +32,7 @@ class ParseHandler(xml.sax.handler.ContentHandler):
- sets up parsing location within the context
- keeps track of ParsePath
- Overall converts a python SAX handler into idl.zapxml.handlers
+ Overall converts a python SAX handler into matter_idl.zapxml.handlers
"""
def __init__(self, include_meta_data=True):
@@ -66,7 +66,8 @@ def endDocument(self):
def startElement(self, name: str, attrs):
logging.debug("ELEMENT START: %r / %r" % (name, attrs))
self._context.path.push(name)
- self._processing_stack.append(self._processing_stack[-1].GetNextProcessor(name, attrs))
+ self._processing_stack.append(
+ self._processing_stack[-1].GetNextProcessor(name, attrs))
def endElement(self, name: str):
logging.debug("ELEMENT END: %r" % name)
@@ -89,7 +90,8 @@ class ParseSource:
Allows for named data sources to be parsed.
"""
source: Union[str, typing.IO] # filename or stream
- name: Optional[str] = None # actual filename to use, None if the source is a filename already
+ # actual filename to use, None if the source is a filename already
+ name: Optional[str] = None
@ property
def source_file_name(self):
diff --git a/scripts/idl/zapxml/handlers/__init__.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py
similarity index 96%
rename from scripts/idl/zapxml/handlers/__init__.py
rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py
index 7a6bfa04682921..3745954a195cfd 100644
--- a/scripts/idl/zapxml/handlers/__init__.py
+++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/__init__.py
@@ -16,7 +16,7 @@
from .context import Context
from .handlers import ConfiguratorHandler
-from idl.matter_idl_types import Idl
+from matter_idl.matter_idl_types import Idl
class ZapXmlHandler(BaseHandler):
diff --git a/scripts/idl/zapxml/handlers/base.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py
similarity index 100%
rename from scripts/idl/zapxml/handlers/base.py
rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/base.py
diff --git a/scripts/idl/zapxml/handlers/context.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py
similarity index 95%
rename from scripts/idl/zapxml/handlers/context.py
rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py
index 2d82153d76d959..b8fd748dfdcfd2 100644
--- a/scripts/idl/zapxml/handlers/context.py
+++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/context.py
@@ -15,7 +15,7 @@
import logging
import xml.sax.xmlreader
-from idl.matter_idl_types import Idl, ParseMetaData, Attribute
+from matter_idl.matter_idl_types import Idl, ParseMetaData, Attribute
from typing import Optional, List
@@ -104,7 +104,8 @@ def AddGlobalAttribute(self, attribute: Attribute):
# NOTE: this may get added several times as both 'client' and 'server'
# however matter should not differentiate between the two
code = attribute.definition.code
- logging.info('Adding global attribute 0x%X (%d): %s' % (code, code, attribute.definition.name))
+ logging.info('Adding global attribute 0x%X (%d): %s' %
+ (code, code, attribute.definition.name))
self._global_attributes[code] = attribute
diff --git a/scripts/idl/zapxml/handlers/handlers.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py
similarity index 96%
rename from scripts/idl/zapxml/handlers/handlers.py
rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py
index 313fc61e8cdbb7..f1396627247a36 100644
--- a/scripts/idl/zapxml/handlers/handlers.py
+++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/handlers.py
@@ -14,7 +14,7 @@
import logging
-from idl.matter_idl_types import *
+from matter_idl.matter_idl_types import *
from typing import Optional, Union, List
from .context import Context, IdlPostProcessor
@@ -245,7 +245,8 @@ class EnumHandler(BaseHandler, IdlPostProcessor):
def __init__(self, context: Context, attrs):
super().__init__(context)
self._cluster_code = None # if set, enum belongs to a specific cluster
- self._enum = Enum(name=attrs['name'], base_type=attrs['type'], entries=[])
+ self._enum = Enum(name=attrs['name'],
+ base_type=attrs['type'], entries=[])
def GetNextProcessor(self, name, attrs):
if name.lower() == 'item':
@@ -256,7 +257,8 @@ def GetNextProcessor(self, name, attrs):
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
elif name.lower() == 'cluster':
if self._cluster_code is not None:
- raise Exception('Multiple cluster codes for enum %s' % self._enum.name)
+ raise Exception(
+ 'Multiple cluster codes for enum %s' % self._enum.name)
self._cluster_code = ParseInt(attrs['code'])
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
else:
@@ -290,7 +292,8 @@ class BitmapHandler(BaseHandler):
def __init__(self, context: Context, attrs):
super().__init__(context)
self._cluster_codes = set()
- self._bitmap = Bitmap(name=attrs['name'], base_type=attrs['type'], entries=[])
+ self._bitmap = Bitmap(
+ name=attrs['name'], base_type=attrs['type'], entries=[])
def GetNextProcessor(self, name, attrs):
if name.lower() == 'cluster':
@@ -410,7 +413,8 @@ def GetNextProcessor(self, name: str, attrs):
if self._command:
self._command.invokeacl = AttrsToAccessPrivilege(attrs)
else:
- logging.warning("Ignored access role for reply %r" % self._struct)
+ logging.warning(
+ "Ignored access role for reply %r" % self._struct)
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
elif name.lower() == 'arg':
self._struct.fields.append(self.GetArgumentField(attrs))
@@ -444,13 +448,15 @@ def GetNextProcessor(self, name: str, attrs):
if name.lower() == 'featurebit':
# It is uncler what featurebits mean. likely a bitmap should be created
# here, however only one such example exists currently: door-lock-cluster.xml
- logging.info('Ignoring featurebit tag for global attribute 0x%X (%d)' % (self._code, self._code))
+ logging.info('Ignoring featurebit tag for global attribute 0x%X (%d)' % (
+ self._code, self._code))
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
else:
return BaseHandler(self.context)
def EndProcessing(self):
- self._cluster.attributes.append(self.context.GetGlobalAttribute(self._code))
+ self._cluster.attributes.append(
+ self.context.GetGlobalAttribute(self._code))
class ClusterHandler(BaseHandler):
@@ -566,7 +572,8 @@ def GetNextProcessor(self, name, attrs):
if attrs['side'].lower() == 'client':
# We expect to also have 'server' equivalent, so ignore client
# side attributes
- logging.debug('Ignoring global client-side attribute %s' % (attrs['code']))
+ logging.debug(
+ 'Ignoring global client-side attribute %s' % (attrs['code']))
return BaseHandler(self.context, handled=HandledDepth.SINGLE_TAG)
return GlobalAttributeHandler(self.context, AttrsToAttribute(attrs))
diff --git a/scripts/idl/zapxml/handlers/parsing.py b/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py
similarity index 98%
rename from scripts/idl/zapxml/handlers/parsing.py
rename to scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py
index f9315f3dab6875..40553edc0d4d1e 100644
--- a/scripts/idl/zapxml/handlers/parsing.py
+++ b/scripts/py_matter_idl/matter_idl/zapxml/handlers/parsing.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from idl.matter_idl_types import *
+from matter_idl.matter_idl_types import *
def ParseInt(value: str) -> int:
diff --git a/scripts/py_matter_idl/pyproject.toml b/scripts/py_matter_idl/pyproject.toml
new file mode 100644
index 00000000000000..ab9c08adaab8b5
--- /dev/null
+++ b/scripts/py_matter_idl/pyproject.toml
@@ -0,0 +1,17 @@
+# Copyright (c) 2022 Project CHIP Authors
+#
+# 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.
+
+[build-system]
+requires = ['setuptools', 'wheel']
+build-backend = 'setuptools.build_meta'
diff --git a/scripts/py_matter_idl/setup.cfg b/scripts/py_matter_idl/setup.cfg
new file mode 100644
index 00000000000000..91e84f82ca8990
--- /dev/null
+++ b/scripts/py_matter_idl/setup.cfg
@@ -0,0 +1,36 @@
+# Copyright (c) 2022 Project CHIP Authors
+#
+# 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.
+
+[metadata]
+name = matter_idl
+version = 0.0.1
+author = Project CHIP Authors
+description = Parse matter idl files
+
+[options]
+packages = find:
+zip_safe = False
+
+[options.package_data]
+matter_idl =
+ lint/lint_rules_grammar.lark
+ matter_grammar.lark
+ generators/java/ChipClustersRead.jinja
+ generators/java/ChipClustersCpp.jinja
+ generators/cpp/application/CallbackStubSource.jinja
+ generators/cpp/application/PluginApplicationCallbacksHeader.jinja
+ generators/bridge/BridgeClustersHeader.jinja
+ generators/bridge/BridgeClustersCommon.jinja
+ generators/bridge/BridgeClustersCpp.jinja
+ generators/bridge/BridgeClustersGlobalStructs.jinja
diff --git a/scripts/idl/setup.py b/scripts/py_matter_idl/setup.py
similarity index 70%
rename from scripts/idl/setup.py
rename to scripts/py_matter_idl/setup.py
index 4566792c40074a..5c10e05ae39916 100644
--- a/scripts/idl/setup.py
+++ b/scripts/py_matter_idl/setup.py
@@ -13,16 +13,8 @@
# limitations under the License.
-"""The idl package."""
+"""The matter_idl package."""
import setuptools # type: ignore
-setuptools.setup(
- name='idl',
- version='0.0.1',
- author='Project CHIP Authors',
- description='Parse matter idl files',
- packages=setuptools.find_packages(),
- package_data={'idl': ['py.typed']},
- zip_safe=False,
-)
+setuptools.setup() # Package definition in setup.cfg
diff --git a/scripts/tests/yamltests/BUILD.gn b/scripts/py_matter_yamltests/BUILD.gn
similarity index 72%
rename from scripts/tests/yamltests/BUILD.gn
rename to scripts/py_matter_yamltests/BUILD.gn
index 2f9a49c0744181..88ba5a41b1cc19 100644
--- a/scripts/tests/yamltests/BUILD.gn
+++ b/scripts/py_matter_yamltests/BUILD.gn
@@ -18,18 +18,22 @@ import("//build_overrides/chip.gni")
import("//build_overrides/pigweed.gni")
import("$dir_pw_build/python.gni")
-pw_python_package("yamltests") {
- setup = [ "setup.py" ]
+pw_python_package("matter_yamltests") {
+ setup = [
+ "setup.py",
+ "setup.cfg",
+ "pyproject.toml",
+ ]
sources = [
- "__init__.py",
- "constraints.py",
- "definitions.py",
- "fixes.py",
- "parser.py",
+ "matter_yamltests/__init__.py",
+ "matter_yamltests/constraints.py",
+ "matter_yamltests/definitions.py",
+ "matter_yamltests/fixes.py",
+ "matter_yamltests/parser.py",
]
- python_deps = [ "${chip_root}/scripts/idl" ]
+ python_deps = [ "${chip_root}/scripts/py_matter_idl:matter_idl" ]
tests = [ "test_spec_definitions.py" ]
diff --git a/scripts/tests/yamltests/__init__.py b/scripts/py_matter_yamltests/matter_yamltests/__init__.py
similarity index 100%
rename from scripts/tests/yamltests/__init__.py
rename to scripts/py_matter_yamltests/matter_yamltests/__init__.py
diff --git a/scripts/tests/yamltests/constraints.py b/scripts/py_matter_yamltests/matter_yamltests/constraints.py
similarity index 100%
rename from scripts/tests/yamltests/constraints.py
rename to scripts/py_matter_yamltests/matter_yamltests/constraints.py
diff --git a/scripts/tests/yamltests/definitions.py b/scripts/py_matter_yamltests/matter_yamltests/definitions.py
similarity index 82%
rename from scripts/tests/yamltests/definitions.py
rename to scripts/py_matter_yamltests/matter_yamltests/definitions.py
index 006704993d7bab..f4b39b134e3f1a 100644
--- a/scripts/tests/yamltests/definitions.py
+++ b/scripts/py_matter_yamltests/matter_yamltests/definitions.py
@@ -16,16 +16,8 @@
from typing import List
import enum
-try:
- from idl.zapxml import ParseSource, ParseXmls
- from idl.matter_idl_types import *
-except:
- import os
- import sys
- sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '../..')))
-
- from idl.zapxml import ParseSource, ParseXmls
- from idl.matter_idl_types import *
+from matter_idl.zapxml import ParseSource, ParseXmls
+from matter_idl.matter_idl_types import *
class _ItemType(enum.Enum):
@@ -66,23 +58,31 @@ def __init__(self, sources: List[ParseSource]):
self.__clusters_by_id[code] = cluster
self.__commands_by_id[code] = {c.code: c for c in cluster.commands}
self.__responses_by_id[code] = {}
- self.__attributes_by_id[code] = {a.definition.code: a for a in cluster.attributes}
+ self.__attributes_by_id[code] = {
+ a.definition.code: a for a in cluster.attributes}
self.__events_by_id[code] = {e.code: e for e in cluster.events}
self.__clusters_by_name[name] = cluster.code
- self.__commands_by_name[name] = {c.name.lower(): c.code for c in cluster.commands}
+ self.__commands_by_name[name] = {
+ c.name.lower(): c.code for c in cluster.commands}
self.__responses_by_name[name] = {}
- self.__attributes_by_name[name] = {a.definition.name.lower(): a.definition.code for a in cluster.attributes}
- self.__events_by_name[name] = {e.name.lower(): e.code for e in cluster.events}
-
- self.__bitmaps_by_name[name] = {b.name.lower(): b for b in cluster.bitmaps}
- self.__enums_by_name[name] = {e.name.lower(): e for e in cluster.enums}
- self.__structs_by_name[name] = {s.name.lower(): s for s in cluster.structs}
+ self.__attributes_by_name[name] = {
+ a.definition.name.lower(): a.definition.code for a in cluster.attributes}
+ self.__events_by_name[name] = {
+ e.name.lower(): e.code for e in cluster.events}
+
+ self.__bitmaps_by_name[name] = {
+ b.name.lower(): b for b in cluster.bitmaps}
+ self.__enums_by_name[name] = {
+ e.name.lower(): e for e in cluster.enums}
+ self.__structs_by_name[name] = {
+ s.name.lower(): s for s in cluster.structs}
for struct in cluster.structs:
if struct.tag == StructTag.RESPONSE:
self.__responses_by_id[code][struct.code] = struct
- self.__responses_by_name[name][struct.name.lower()] = struct.code
+ self.__responses_by_name[name][struct.name.lower(
+ )] = struct.code
def get_cluster_name(self, cluster_id: int) -> str:
cluster = self.__clusters_by_id.get(cluster_id)
@@ -93,11 +93,13 @@ def get_command_name(self, cluster_id: int, command_id: int) -> str:
return command.name if command else None
def get_response_name(self, cluster_id: int, response_id: int) -> str:
- response = self.__get_by_id(cluster_id, response_id, _ItemType.Response)
+ response = self.__get_by_id(
+ cluster_id, response_id, _ItemType.Response)
return response.name if response else None
def get_attribute_name(self, cluster_id: int, attribute_id: int) -> str:
- attribute = self.__get_by_id(cluster_id, attribute_id, _ItemType.Attribute)
+ attribute = self.__get_by_id(
+ cluster_id, attribute_id, _ItemType.Attribute)
return attribute.definition.name if attribute else None
def get_event_name(self, cluster_id: int, event_id: int) -> str:
@@ -162,16 +164,20 @@ def __get_by_name(self, cluster_name: str, target_name: str, target_type: _ItemT
target = None
if target_type == _ItemType.Request:
- target_id = self.__commands_by_name.get(cluster_name).get(target_name)
+ target_id = self.__commands_by_name.get(
+ cluster_name).get(target_name)
target = self.__get_by_id(cluster_id, target_id, target_type)
elif target_type == _ItemType.Response:
- target_id = self.__responses_by_name.get(cluster_name).get(target_name)
+ target_id = self.__responses_by_name.get(
+ cluster_name).get(target_name)
target = self.__get_by_id(cluster_id, target_id, target_type)
elif target_type == _ItemType.Event:
- target_id = self.__events_by_name.get(cluster_name).get(target_name)
+ target_id = self.__events_by_name.get(
+ cluster_name).get(target_name)
target = self.__get_by_id(cluster_id, target_id, target_type)
elif target_type == _ItemType.Attribute:
- target_id = self.__attributes_by_name.get(cluster_name).get(target_name)
+ target_id = self.__attributes_by_name.get(
+ cluster_name).get(target_name)
target = self.__get_by_id(cluster_id, target_id, target_type)
elif target_type == _ItemType.Bitmap:
target = self.__bitmaps_by_name.get(cluster_name).get(target_name)
diff --git a/scripts/tests/yamltests/fixes.py b/scripts/py_matter_yamltests/matter_yamltests/fixes.py
similarity index 100%
rename from scripts/tests/yamltests/fixes.py
rename to scripts/py_matter_yamltests/matter_yamltests/fixes.py
diff --git a/scripts/tests/yamltests/parser.py b/scripts/py_matter_yamltests/matter_yamltests/parser.py
similarity index 100%
rename from scripts/tests/yamltests/parser.py
rename to scripts/py_matter_yamltests/matter_yamltests/parser.py
diff --git a/scripts/py_matter_yamltests/pyproject.toml b/scripts/py_matter_yamltests/pyproject.toml
new file mode 100644
index 00000000000000..ab9c08adaab8b5
--- /dev/null
+++ b/scripts/py_matter_yamltests/pyproject.toml
@@ -0,0 +1,17 @@
+# Copyright (c) 2022 Project CHIP Authors
+#
+# 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.
+
+[build-system]
+requires = ['setuptools', 'wheel']
+build-backend = 'setuptools.build_meta'
diff --git a/scripts/py_matter_yamltests/setup.cfg b/scripts/py_matter_yamltests/setup.cfg
new file mode 100644
index 00000000000000..497022ce1459d9
--- /dev/null
+++ b/scripts/py_matter_yamltests/setup.cfg
@@ -0,0 +1,24 @@
+# Copyright (c) 2022 Project CHIP Authors
+#
+# 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.
+
+[metadata]
+name = matter_yamltests
+version = 0.0.1
+author = Project CHIP Authors
+description = Parse matter yaml tests files
+
+[options]
+packages = find:
+
+zip_safe = False
diff --git a/scripts/tests/yamltests/setup.py b/scripts/py_matter_yamltests/setup.py
similarity index 68%
rename from scripts/tests/yamltests/setup.py
rename to scripts/py_matter_yamltests/setup.py
index 2bcdfbe8c61d46..2d7f786e1957f6 100644
--- a/scripts/tests/yamltests/setup.py
+++ b/scripts/py_matter_yamltests/setup.py
@@ -13,16 +13,8 @@
# limitations under the License.
-"""The yamltest package."""
+"""The yamltests package."""
import setuptools # type: ignore
-setuptools.setup(
- name='yamltests',
- version='0.0.1',
- author='Project CHIP Authors',
- description='Parse matter yaml test files',
- packages=setuptools.find_packages(),
- package_data={'yamltest': ['py.typed']},
- zip_safe=False,
-)
+setuptools.setup() # Package definition in setup.cfg
diff --git a/scripts/py_matter_yamltests/test_spec_definitions.py b/scripts/py_matter_yamltests/test_spec_definitions.py
new file mode 100644
index 00000000000000..35a2dcd29f911a
--- /dev/null
+++ b/scripts/py_matter_yamltests/test_spec_definitions.py
@@ -0,0 +1,358 @@
+#!/usr/bin/env -S python3 -B
+#
+# Copyright (c) 2022 Project CHIP Authors
+#
+# 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.
+
+from matter_yamltests.definitions import *
+
+import unittest
+import io
+
+source_cluster = '''
+
+
+ Test
+ 0x1234
+
+
+'''
+
+source_command = '''
+
+
+ Test
+ 0x1234
+
+
+
+
+
+'''
+
+source_response = '''
+
+
+ Test
+ 0x1234
+
+
+
+
+
+
+
+'''
+
+source_attribute = '''
+
+
+ TestGlobalAttribute
+
+
+
+ Test
+ 0x1234
+
+
+ TestAttribute
+
+
+
+'''
+
+source_event = '''
+
+
+ Test
+ 0x1234
+
+
+
+
+
+'''
+
+source_bitmap = '''
+
+
+
+
+
+
+
+
+
+
+
+
+ Test
+ 0x1234
+
+
+
+ TestWrong
+ 0x4321
+
+
+'''
+
+source_enum = '''
+
+
+
+
+
+
+
+
+
+
+
+
+ Test
+ 0x1234
+
+
+
+ TestWrong
+ 0x4321
+
+
+'''
+
+source_struct = '''
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Test
+ 0x1234
+
+
+
+ TestWrong
+ 0x4321
+
+
+'''
+
+
+class TestSpecDefinitions(unittest.TestCase):
+ def test_cluster_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_cluster), name='source_cluster')])
+ self.assertIsNone(definitions.get_cluster_name(0x4321))
+ self.assertEqual(definitions.get_cluster_name(0x1234), 'Test')
+
+ def test_command_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_command), name='source_command')])
+ self.assertIsNone(definitions.get_command_name(0x4321, 0x0))
+ self.assertIsNone(definitions.get_command_name(0x1234, 0x1))
+ self.assertEqual(definitions.get_command_name(
+ 0x1234, 0x0), 'TestCommand')
+
+ def test_response_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_response), name='source_response')])
+ self.assertIsNone(definitions.get_response_name(0x4321, 0x0))
+ self.assertIsNone(definitions.get_response_name(0x1234, 0x1))
+ self.assertEqual(definitions.get_response_name(
+ 0x1234, 0x0), 'TestCommandResponse')
+
+ def test_attribute_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')])
+ self.assertIsNone(definitions.get_attribute_name(0x4321, 0x0))
+ self.assertIsNone(definitions.get_attribute_name(0x4321, 0xFFFD))
+ self.assertIsNone(definitions.get_attribute_name(0x1234, 0x1))
+ self.assertEqual(definitions.get_attribute_name(
+ 0x1234, 0x0), 'TestAttribute')
+ self.assertEqual(definitions.get_attribute_name(
+ 0x1234, 0xFFFD), 'TestGlobalAttribute')
+
+ def test_event_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_event), name='source_event')])
+ self.assertIsNone(definitions.get_event_name(0x4321, 0x0))
+ self.assertIsNone(definitions.get_event_name(0x1234, 0x1))
+ self.assertEqual(definitions.get_event_name(0x1234, 0x0), 'TestEvent')
+
+ def test_get_command_by_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_command), name='source_command')])
+ self.assertIsNone(definitions.get_command_by_name(
+ 'WrongName', 'TestCommand'))
+ self.assertIsNone(definitions.get_command_by_name(
+ 'Test', 'TestWrongCommand'))
+ self.assertIsNone(
+ definitions.get_response_by_name('Test', 'TestCommand'))
+ self.assertIsInstance(definitions.get_command_by_name(
+ 'Test', 'TestCommand'), Command)
+ self.assertIsNone(
+ definitions.get_command_by_name('test', 'TestCommand'))
+ self.assertIsInstance(definitions.get_command_by_name(
+ 'Test', 'testcommand'), Command)
+
+ def test_get_response_by_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_response), name='source_response')])
+ self.assertIsNone(definitions.get_response_by_name(
+ 'WrongName', 'TestCommandResponse'))
+ self.assertIsNone(definitions.get_response_by_name(
+ 'Test', 'TestWrongCommandResponse'))
+ self.assertIsNone(definitions.get_command_by_name(
+ 'Test', 'TestCommandResponse'))
+ self.assertIsInstance(definitions.get_response_by_name(
+ 'Test', 'TestCommandResponse'), Struct)
+ self.assertIsNone(definitions.get_response_by_name(
+ 'test', 'TestCommandResponse'))
+ self.assertIsInstance(definitions.get_response_by_name(
+ 'Test', 'testcommandresponse'), Struct)
+
+ def test_get_attribute_by_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')])
+ self.assertIsNone(definitions.get_attribute_by_name(
+ 'WrongName', 'TestAttribute'))
+ self.assertIsNone(definitions.get_attribute_by_name(
+ 'WrongName', 'TestGlobalAttribute'))
+ self.assertIsNone(definitions.get_attribute_by_name(
+ 'Test', 'TestWrongAttribute'))
+ self.assertIsInstance(definitions.get_attribute_by_name(
+ 'Test', 'TestAttribute'), Attribute)
+ self.assertIsInstance(definitions.get_attribute_by_name(
+ 'Test', 'TestGlobalAttribute'), Attribute)
+ self.assertIsNone(definitions.get_attribute_by_name(
+ 'test', 'TestAttribute'))
+ self.assertIsNone(definitions.get_attribute_by_name(
+ 'test', 'TestGlobalAttribute'))
+ self.assertIsInstance(definitions.get_attribute_by_name(
+ 'Test', 'testattribute'), Attribute)
+ self.assertIsInstance(definitions.get_attribute_by_name(
+ 'Test', 'testglobalattribute'), Attribute)
+
+ def test_get_event_by_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_event), name='source_event')])
+ self.assertIsNone(definitions.get_event_by_name(
+ 'WrongName', 'TestEvent'))
+ self.assertIsNone(definitions.get_event_by_name(
+ 'Test', 'TestWrongEvent'))
+ self.assertIsInstance(
+ definitions.get_event_by_name('Test', 'TestEvent'), Event)
+ self.assertIsNone(definitions.get_event_by_name('test', 'TestEvent'))
+ self.assertIsInstance(
+ definitions.get_event_by_name('Test', 'testevent'), Event)
+
+ def test_get_bitmap_by_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')])
+ self.assertIsNone(definitions.get_bitmap_by_name(
+ 'WrongName', 'TestBitmap'))
+ self.assertIsNone(definitions.get_bitmap_by_name(
+ 'Test', 'TestWrongBitmap'))
+ self.assertIsInstance(definitions.get_bitmap_by_name(
+ 'Test', 'TestBitmap'), Bitmap)
+ self.assertIsNone(definitions.get_bitmap_by_name('test', 'TestBitmap'))
+ self.assertIsInstance(definitions.get_bitmap_by_name(
+ 'Test', 'testbitmap'), Bitmap)
+
+ def test_get_enum_by_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_enum), name='source_enum')])
+ self.assertIsNone(definitions.get_enum_by_name(
+ 'WrongName', 'TestEnum'))
+ self.assertIsNone(definitions.get_enum_by_name(
+ 'Test', 'TestWrongEnum'))
+ self.assertIsInstance(
+ definitions.get_enum_by_name('Test', 'TestEnum'), Enum)
+ self.assertIsNone(definitions.get_enum_by_name('test', 'TestEnum'))
+ self.assertIsInstance(
+ definitions.get_enum_by_name('Test', 'testenum'), Enum)
+
+ def test_get_struct_by_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_struct), name='source_struct')])
+ self.assertIsNone(definitions.get_struct_by_name(
+ 'WrongName', 'TestStruct'))
+ self.assertIsNone(definitions.get_struct_by_name(
+ 'Test', 'TestWrongStruct'))
+ self.assertIsInstance(definitions.get_struct_by_name(
+ 'Test', 'TestStruct'), Struct)
+ self.assertIsNone(definitions.get_struct_by_name('test', 'TestStruct'))
+ self.assertIsInstance(definitions.get_struct_by_name(
+ 'Test', 'teststruct'), Struct)
+
+ def test_get_type_by_name(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_command), name='source_command')])
+ self.assertIsNone(definitions.get_type_by_name('Test', 'TestCommand'))
+
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_response), name='source_response')])
+ self.assertIsInstance(definitions.get_type_by_name(
+ 'Test', 'TestCommandResponse'), Struct)
+
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_attribute), name='source_attribute')])
+ self.assertIsNone(definitions.get_type_by_name(
+ 'Test', 'TestAttribute'))
+
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_event), name='source_event')])
+ self.assertIsNone(definitions.get_type_by_name('Test', 'TestEvent'))
+
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')])
+ self.assertIsInstance(definitions.get_type_by_name(
+ 'Test', 'TestBitmap'), Bitmap)
+
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_enum), name='source_enum')])
+ self.assertIsInstance(
+ definitions.get_type_by_name('Test', 'TestEnum'), Enum)
+
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_struct), name='source_struct')])
+ self.assertIsInstance(definitions.get_type_by_name(
+ 'Test', 'TestStruct'), Struct)
+
+ def test_is_fabric_scoped(self):
+ definitions = SpecDefinitions(
+ [ParseSource(source=io.StringIO(source_struct), name='source_struct')])
+
+ struct = definitions.get_struct_by_name('Test', 'TestStruct')
+ self.assertFalse(definitions.is_fabric_scoped(struct))
+
+ struct = definitions.get_struct_by_name(
+ 'Test', 'TestStructFabricScoped')
+ self.assertTrue(definitions.is_fabric_scoped(struct))
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/scripts/tests/test_yaml_parser.py b/scripts/py_matter_yamltests/test_yaml_parser.py
similarity index 92%
rename from scripts/tests/test_yaml_parser.py
rename to scripts/py_matter_yamltests/test_yaml_parser.py
index c6a73da4f8eed9..78df2c35fe64ad 100644
--- a/scripts/tests/test_yaml_parser.py
+++ b/scripts/py_matter_yamltests/test_yaml_parser.py
@@ -23,8 +23,8 @@
import tempfile
import unittest
-from yamltests.definitions import *
-from yamltests.parser import TestParser
+from matter_yamltests.definitions import *
+from matter_yamltests.parser import TestParser
simple_test_description = '''
@@ -75,7 +75,8 @@ def setUp(self):
with open(self._temp_file.name, 'w') as f:
f.writelines(simple_test_yaml)
pics_file = None
- self._yaml_parser = TestParser(self._temp_file.name, pics_file, self._definitions)
+ self._yaml_parser = TestParser(
+ self._temp_file.name, pics_file, self._definitions)
def test_able_to_iterate_over_all_parsed_tests(self):
# self._yaml_parser.tests implements `__next__`, which does value substitution. We are
diff --git a/scripts/requirements.txt b/scripts/requirements.txt
index b39ec86833bf6e..eb7b423cd90b05 100644
--- a/scripts/requirements.txt
+++ b/scripts/requirements.txt
@@ -69,8 +69,9 @@ tabulate
# scripts/build
click
-# scripts/idl
+# scripts/py_matter_idl/matter_idl
lark
+# scripts/py_matter_idl/matter_idl and scripts/py_matter_yamtests/matter_yamltests
stringcase
cryptography
diff --git a/scripts/tests/yamltests/test_spec_definitions.py b/scripts/tests/yamltests/test_spec_definitions.py
deleted file mode 100644
index 00a15da9940d0c..00000000000000
--- a/scripts/tests/yamltests/test_spec_definitions.py
+++ /dev/null
@@ -1,291 +0,0 @@
-#!/usr/bin/env -S python3 -B
-#
-# Copyright (c) 2022 Project CHIP Authors
-#
-# 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.
-
-from definitions import *
-
-import unittest
-import io
-
-source_cluster = '''
-
-
- Test
- 0x1234
-
-
-'''
-
-source_command = '''
-
-
- Test
- 0x1234
-
-
-
-
-
-'''
-
-source_response = '''
-
-
- Test
- 0x1234
-
-
-
-
-
-
-
-'''
-
-source_attribute = '''
-
-
- TestGlobalAttribute
-
-
-
- Test
- 0x1234
-
-
- TestAttribute
-
-
-
-'''
-
-source_event = '''
-
-
- Test
- 0x1234
-
-
-
-
-
-'''
-
-source_bitmap = '''
-
-
-
-
-
-
-
-
-
-
-
-
- Test
- 0x1234
-
-
-
- TestWrong
- 0x4321
-
-
-'''
-
-source_enum = '''
-
-
-
-
-
-
-
-
-
-
-
-
- Test
- 0x1234
-
-
-
- TestWrong
- 0x4321
-
-
-'''
-
-source_struct = '''
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Test
- 0x1234
-
-
-
- TestWrong
- 0x4321
-
-
-'''
-
-
-class TestSpecDefinitions(unittest.TestCase):
- def test_cluster_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_cluster), name='source_cluster')])
- self.assertIsNone(definitions.get_cluster_name(0x4321))
- self.assertEqual(definitions.get_cluster_name(0x1234), 'Test')
-
- def test_command_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')])
- self.assertIsNone(definitions.get_command_name(0x4321, 0x0))
- self.assertIsNone(definitions.get_command_name(0x1234, 0x1))
- self.assertEqual(definitions.get_command_name(0x1234, 0x0), 'TestCommand')
-
- def test_response_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')])
- self.assertIsNone(definitions.get_response_name(0x4321, 0x0))
- self.assertIsNone(definitions.get_response_name(0x1234, 0x1))
- self.assertEqual(definitions.get_response_name(0x1234, 0x0), 'TestCommandResponse')
-
- def test_attribute_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')])
- self.assertIsNone(definitions.get_attribute_name(0x4321, 0x0))
- self.assertIsNone(definitions.get_attribute_name(0x4321, 0xFFFD))
- self.assertIsNone(definitions.get_attribute_name(0x1234, 0x1))
- self.assertEqual(definitions.get_attribute_name(0x1234, 0x0), 'TestAttribute')
- self.assertEqual(definitions.get_attribute_name(0x1234, 0xFFFD), 'TestGlobalAttribute')
-
- def test_event_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')])
- self.assertIsNone(definitions.get_event_name(0x4321, 0x0))
- self.assertIsNone(definitions.get_event_name(0x1234, 0x1))
- self.assertEqual(definitions.get_event_name(0x1234, 0x0), 'TestEvent')
-
- def test_get_command_by_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')])
- self.assertIsNone(definitions.get_command_by_name('WrongName', 'TestCommand'))
- self.assertIsNone(definitions.get_command_by_name('Test', 'TestWrongCommand'))
- self.assertIsNone(definitions.get_response_by_name('Test', 'TestCommand'))
- self.assertIsInstance(definitions.get_command_by_name('Test', 'TestCommand'), Command)
- self.assertIsNone(definitions.get_command_by_name('test', 'TestCommand'))
- self.assertIsInstance(definitions.get_command_by_name('Test', 'testcommand'), Command)
-
- def test_get_response_by_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')])
- self.assertIsNone(definitions.get_response_by_name('WrongName', 'TestCommandResponse'))
- self.assertIsNone(definitions.get_response_by_name('Test', 'TestWrongCommandResponse'))
- self.assertIsNone(definitions.get_command_by_name('Test', 'TestCommandResponse'))
- self.assertIsInstance(definitions.get_response_by_name('Test', 'TestCommandResponse'), Struct)
- self.assertIsNone(definitions.get_response_by_name('test', 'TestCommandResponse'))
- self.assertIsInstance(definitions.get_response_by_name('Test', 'testcommandresponse'), Struct)
-
- def test_get_attribute_by_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')])
- self.assertIsNone(definitions.get_attribute_by_name('WrongName', 'TestAttribute'))
- self.assertIsNone(definitions.get_attribute_by_name('WrongName', 'TestGlobalAttribute'))
- self.assertIsNone(definitions.get_attribute_by_name('Test', 'TestWrongAttribute'))
- self.assertIsInstance(definitions.get_attribute_by_name('Test', 'TestAttribute'), Attribute)
- self.assertIsInstance(definitions.get_attribute_by_name('Test', 'TestGlobalAttribute'), Attribute)
- self.assertIsNone(definitions.get_attribute_by_name('test', 'TestAttribute'))
- self.assertIsNone(definitions.get_attribute_by_name('test', 'TestGlobalAttribute'))
- self.assertIsInstance(definitions.get_attribute_by_name('Test', 'testattribute'), Attribute)
- self.assertIsInstance(definitions.get_attribute_by_name('Test', 'testglobalattribute'), Attribute)
-
- def test_get_event_by_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')])
- self.assertIsNone(definitions.get_event_by_name('WrongName', 'TestEvent'))
- self.assertIsNone(definitions.get_event_by_name('Test', 'TestWrongEvent'))
- self.assertIsInstance(definitions.get_event_by_name('Test', 'TestEvent'), Event)
- self.assertIsNone(definitions.get_event_by_name('test', 'TestEvent'))
- self.assertIsInstance(definitions.get_event_by_name('Test', 'testevent'), Event)
-
- def test_get_bitmap_by_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')])
- self.assertIsNone(definitions.get_bitmap_by_name('WrongName', 'TestBitmap'))
- self.assertIsNone(definitions.get_bitmap_by_name('Test', 'TestWrongBitmap'))
- self.assertIsInstance(definitions.get_bitmap_by_name('Test', 'TestBitmap'), Bitmap)
- self.assertIsNone(definitions.get_bitmap_by_name('test', 'TestBitmap'))
- self.assertIsInstance(definitions.get_bitmap_by_name('Test', 'testbitmap'), Bitmap)
-
- def test_get_enum_by_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_enum), name='source_enum')])
- self.assertIsNone(definitions.get_enum_by_name('WrongName', 'TestEnum'))
- self.assertIsNone(definitions.get_enum_by_name('Test', 'TestWrongEnum'))
- self.assertIsInstance(definitions.get_enum_by_name('Test', 'TestEnum'), Enum)
- self.assertIsNone(definitions.get_enum_by_name('test', 'TestEnum'))
- self.assertIsInstance(definitions.get_enum_by_name('Test', 'testenum'), Enum)
-
- def test_get_struct_by_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')])
- self.assertIsNone(definitions.get_struct_by_name('WrongName', 'TestStruct'))
- self.assertIsNone(definitions.get_struct_by_name('Test', 'TestWrongStruct'))
- self.assertIsInstance(definitions.get_struct_by_name('Test', 'TestStruct'), Struct)
- self.assertIsNone(definitions.get_struct_by_name('test', 'TestStruct'))
- self.assertIsInstance(definitions.get_struct_by_name('Test', 'teststruct'), Struct)
-
- def test_get_type_by_name(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_command), name='source_command')])
- self.assertIsNone(definitions.get_type_by_name('Test', 'TestCommand'))
-
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_response), name='source_response')])
- self.assertIsInstance(definitions.get_type_by_name('Test', 'TestCommandResponse'), Struct)
-
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_attribute), name='source_attribute')])
- self.assertIsNone(definitions.get_type_by_name('Test', 'TestAttribute'))
-
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_event), name='source_event')])
- self.assertIsNone(definitions.get_type_by_name('Test', 'TestEvent'))
-
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_bitmap), name='source_bitmap')])
- self.assertIsInstance(definitions.get_type_by_name('Test', 'TestBitmap'), Bitmap)
-
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_enum), name='source_enum')])
- self.assertIsInstance(definitions.get_type_by_name('Test', 'TestEnum'), Enum)
-
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')])
- self.assertIsInstance(definitions.get_type_by_name('Test', 'TestStruct'), Struct)
-
- def test_is_fabric_scoped(self):
- definitions = SpecDefinitions([ParseSource(source=io.StringIO(source_struct), name='source_struct')])
-
- struct = definitions.get_struct_by_name('Test', 'TestStruct')
- self.assertFalse(definitions.is_fabric_scoped(struct))
-
- struct = definitions.get_struct_by_name('Test', 'TestStructFabricScoped')
- self.assertTrue(definitions.is_fabric_scoped(struct))
-
-
-if __name__ == '__main__':
- unittest.main()