parent
68c3d7309a
commit
6926725e02
@ -223,11 +223,11 @@ class DeviceCollection(object):
|
|||||||
persistent=persistent)
|
persistent=persistent)
|
||||||
result = []
|
result = []
|
||||||
for dev, options in devices:
|
for dev, options in devices:
|
||||||
if dev in self._set and persistent is False:
|
if dev in self._set and not persistent:
|
||||||
continue
|
continue
|
||||||
elif dev in self._set:
|
elif dev in self._set:
|
||||||
result.append(self._set.get(dev))
|
result.append(self._set.get(dev))
|
||||||
elif dev not in self._set and persistent is True:
|
elif dev not in self._set and persistent:
|
||||||
continue
|
continue
|
||||||
else:
|
else:
|
||||||
result.append(
|
result.append(
|
||||||
@ -374,20 +374,12 @@ class PersistentCollection(object):
|
|||||||
del self._dict[key]
|
del self._dict[key]
|
||||||
|
|
||||||
def __contains__(self, device) -> bool:
|
def __contains__(self, device) -> bool:
|
||||||
vm = device.backend_domain
|
return (device.backend_domain, device.ident) in self._dict
|
||||||
ident = device.ident
|
|
||||||
key = (vm, ident)
|
|
||||||
return key in self._dict
|
|
||||||
|
|
||||||
def get(self, device: DeviceInfo) -> DeviceAssignment:
|
def get(self, device: DeviceInfo) -> DeviceAssignment:
|
||||||
''' Returns the corresponding `qubes.devices.DeviceAssignment` for the
|
''' Returns the corresponding `qubes.devices.DeviceAssignment` for the
|
||||||
device. '''
|
device. '''
|
||||||
vm = device.backend_domain
|
return self._dict[(device.backend_domain, device.ident)]
|
||||||
ident = device.ident
|
|
||||||
key = (vm, ident)
|
|
||||||
if key not in self._dict:
|
|
||||||
raise KeyError
|
|
||||||
return self._dict[key]
|
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
return self._dict.values().__iter__()
|
return self._dict.values().__iter__()
|
||||||
|
Loading…
Reference in New Issue
Block a user