Skip to content

Commit

Permalink
Merge pull request #38 from boutproject/DataFile-get-method
Browse files Browse the repository at this point in the history
DataFile.get() method
  • Loading branch information
johnomotani authored Mar 14, 2022
2 parents f7b8b59 + 1a6e635 commit c94705f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions boututils/datafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ def read_file_attribute(self, name):
def write_file_attribute(self, name, value):
return self.impl.write_file_attribute(name, value)

def get(self, name, default=None):
if default is None or name in self.keys():
return self[name]
else:
return default

def __getitem__(self, name):
return self.impl.__getitem__(name)

Expand Down

0 comments on commit c94705f

Please sign in to comment.