Skip to content

Commit

Permalink
Add Qubes.domains.get() method
Browse files Browse the repository at this point in the history
Make it more similar to a normal dict.
  • Loading branch information
marmarek committed Aug 4, 2021
1 parent d0be4ee commit 0a00c45
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions qubesadmin/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,15 @@ def get_blind(self, item):
power_state=power_state)
return self._vm_objects[item]

def get(self, item, default=None):
"""
Get a VM object, or return *default* if it can't be found.
"""
try:
return self[item]
except KeyError:
return default

def __contains__(self, item):
if isinstance(item, qubesadmin.vm.QubesVM):
item = item.name
Expand Down

0 comments on commit 0a00c45

Please sign in to comment.