Skip to content

Commit

Permalink
Adds a get method to Dataconverter Template
Browse files Browse the repository at this point in the history
  • Loading branch information
sherjeelshabih committed Dec 2, 2023
1 parent ecce57a commit 8d8f0ee
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pynxtools/dataconverter/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,13 @@ def __contains__(self, k):
k in self.required
])

def get(self, key: str, default=None):
"""Proxies the get function to our internal __getitem__"""
try:
return self[key]
except KeyError:
return default

def __getitem__(self, k):
"""Handles how values are accessed from the Template object."""
# Try setting item in all else throw error. Does not append to default.
Expand Down

0 comments on commit 8d8f0ee

Please sign in to comment.