Skip to content

Commit

Permalink
add default for config.get
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey committed Jan 24, 2025
1 parent 983d44c commit e87ba9b
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions h5pyd/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ def __getitem__(self, name):
else:
return None
return Config._cfg[name]

def get(self, name):
""" alias for __getitem__ """
return self.__getitem__(name)

def get(self, name, default):
""" return option for name if found, otherwise default """
val = self.__getitem__(name)
if val is None:
val = default
return val

def __setitem__(self, name, obj):
""" set config item """
Expand Down

0 comments on commit e87ba9b

Please sign in to comment.