mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
netcmd: models: Rename method to Query._from_message for consistency
Signed-off-by: Rob van der Linde <rob@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
This commit is contained in:
parent
a1345442cc
commit
3d36707908
@ -42,9 +42,9 @@ class Query:
|
||||
def __iter__(self):
|
||||
"""Loop over Query class yields Model instances."""
|
||||
for message in self.result:
|
||||
yield self._model_from_message(message)
|
||||
yield self._from_message(message)
|
||||
|
||||
def _model_from_message(self, message):
|
||||
def _from_message(self, message):
|
||||
"""Returns the model class to use to construct instances.
|
||||
|
||||
If polymorphic query is enabled it will use the last item from
|
||||
@ -63,12 +63,12 @@ class Query:
|
||||
def first(self):
|
||||
"""Returns the first item in the Query or None for no results."""
|
||||
if self.count:
|
||||
return self._model_from_message(self.result[0])
|
||||
return self._from_message(self.result[0])
|
||||
|
||||
def last(self):
|
||||
"""Returns the last item in the Query or None for no results."""
|
||||
if self.count:
|
||||
return self._model_from_message(self.result[-1])
|
||||
return self._from_message(self.result[-1])
|
||||
|
||||
def get(self):
|
||||
"""Returns one item or None if no results were found.
|
||||
@ -80,7 +80,7 @@ class Query:
|
||||
raise MultipleObjectsReturned(
|
||||
f"More than one {self.name} objects returned (got {self.count}).")
|
||||
elif self.count:
|
||||
return self._model_from_message(self.result[0])
|
||||
return self._from_message(self.result[0])
|
||||
|
||||
def one(self):
|
||||
"""Must return EXACTLY one item or raise an exception.
|
||||
@ -96,4 +96,4 @@ class Query:
|
||||
raise MultipleObjectsReturned(
|
||||
f"More than one {self.name} objects returned (got {self.count}).")
|
||||
else:
|
||||
return self._model_from_message(self.result[0])
|
||||
return self._from_message(self.result[0])
|
||||
|
Loading…
Reference in New Issue
Block a user