Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Convert former python yaml tests parser to be a runner/adapter #24103

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions scripts/tests/yamltests/fixes.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ def try_apply_yaml_float_written_as_strings(value):
return value


# TODO(thampson) This method is a clone of the method in
# src/controller/python/chip/yaml/format_converter.py and should eventually be removed in that file.
def convert_yaml_octet_string_to_bytes(s: str) -> bytes:
'''Convert YAML octet string body to bytes.

Expand Down
4 changes: 1 addition & 3 deletions src/controller/python/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,10 @@ chip_python_wheel_action("chip-core") {
"chip/utils/CommissioningBuildingBlocks.py",
"chip/utils/__init__.py",
"chip/yaml/__init__.py",
"chip/yaml/constraints.py",
"chip/yaml/data_model_lookup.py",
"chip/yaml/errors.py",
"chip/yaml/format_converter.py",
"chip/yaml/parser.py",
"chip/yaml/variable_storage.py",
"chip/yaml/runner.py",
]

if (chip_controller) {
Expand Down
2 changes: 1 addition & 1 deletion src/controller/python/chip/yaml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@
# Provides Python APIs for Matter.

"""Provides yaml parser Python APIs for Matter."""
from . import parser
from . import runner
221 changes: 0 additions & 221 deletions src/controller/python/chip/yaml/constraints.py

This file was deleted.

11 changes: 11 additions & 0 deletions src/controller/python/chip/yaml/data_model_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def get_command(self, cluster: str, command: str):
def get_attribute(self, cluster: str, attribute: str):
pass

@abstractmethod
def get_event(self, cluster: str, event: str):
pass


class PreDefinedDataModelLookup(DataModelLookup):
def get_cluster(self, cluster: str):
Expand All @@ -53,3 +57,10 @@ def get_attribute(self, cluster: str, attribute: str):
return getattr(attributes, attribute, None)
except AttributeError:
return None

def get_event(self, cluster: str, event: str):
try:
events = getattr(Clusters, cluster, None).Events
return getattr(events, event, None)
except AttributeError:
return None
2 changes: 1 addition & 1 deletion src/controller/python/chip/yaml/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def __init__(self, message):
super().__init__(message)


class UnexpectedParsingError(ParsingError):
class UnexpectedParsingError(ValueError):
def __init__(self, message):
super().__init__(message)

Expand Down
Loading