Merge pull request #992 from mwhudson/generalize-_one-_all
make two FilesystemModel helper methods slightly more general
This commit is contained in:
commit
cf75408e46
|
@ -1232,24 +1232,22 @@ class FilesystemModel(object):
|
|||
self._probe_data = probe_data
|
||||
self.reset()
|
||||
|
||||
def _matcher(self, type, kw):
|
||||
def _matcher(self, kw):
|
||||
for a in self._actions:
|
||||
if a.type != type:
|
||||
continue
|
||||
for k, v in kw.items():
|
||||
if getattr(a, k) != v:
|
||||
break
|
||||
else:
|
||||
yield a
|
||||
|
||||
def _one(self, *, type, **kw):
|
||||
def _one(self, **kw):
|
||||
try:
|
||||
return next(self._matcher(type, kw))
|
||||
return next(self._matcher(kw))
|
||||
except StopIteration:
|
||||
return None
|
||||
|
||||
def _all(self, *, type, **kw):
|
||||
return list(self._matcher(type, kw))
|
||||
def _all(self, **kw):
|
||||
return list(self._matcher(kw))
|
||||
|
||||
def all_mounts(self):
|
||||
return self._all(type='mount')
|
||||
|
|
|
@ -234,7 +234,7 @@ class FilesystemController(SubiquityController, FilesystemManipulator):
|
|||
async def guided_POST(self, choice: Optional[GuidedChoice]) \
|
||||
-> StorageResponse:
|
||||
if choice is not None:
|
||||
disk = self.model._one(type='disk', id=choice.disk_id)
|
||||
disk = self.model._one(id=choice.disk_id)
|
||||
if choice.use_lvm:
|
||||
lvm_options = None
|
||||
if choice.password is not None:
|
||||
|
|
Loading…
Reference in New Issue