Skip to content

Commit

Permalink
add a __getitem__ method to SnappyModel for good measure / backwards …
Browse files Browse the repository at this point in the history
…compatibility
  • Loading branch information
tedil committed May 31, 2024
1 parent f27c1dd commit b76a4b5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions snappy_pipeline/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ def get(self, key: str, default: typing.Any = None) -> typing.Any:
"""
return getattr(self, key, default)

def __getitem__(self, item: str) -> typing.Any:
"""
Return the value of the field with the given key.
Raise an AttributeError if the field doesn't exist.
"""
return getattr(self, item)

# This exists to distinguish workflow step_config models from other snappy specific models
# It also provides a default_config_yaml_string method that includes the step_config section
Expand Down

0 comments on commit b76a4b5

Please sign in to comment.