forked from Advanced_Python/advanced-python-homework-2023
fix after review
This commit is contained in:
parent
c524ddeb1a
commit
e35ac53eda
@ -44,9 +44,7 @@ class TurtleDevice(SynchronyDevice):
|
|||||||
"""Execute action `action_name`, using `args` and `kwargs` as action argument."""
|
"""Execute action `action_name`, using `args` and `kwargs` as action argument."""
|
||||||
action = self.get_descriptors()["actions"].get(action_name)
|
action = self.get_descriptors()["actions"].get(action_name)
|
||||||
if action:
|
if action:
|
||||||
self._state = DeviceLifecycleState.CLOSE
|
|
||||||
getattr(self.turtle, action_name)(*args, **kwargs)
|
getattr(self.turtle, action_name)(*args, **kwargs)
|
||||||
self._state = DeviceLifecycleState.OPEN
|
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
raise DeviceError("No such action: `{}`".format(action_name))
|
raise DeviceError("No such action: `{}`".format(action_name))
|
||||||
@ -59,11 +57,6 @@ class TurtleDevice(SynchronyDevice):
|
|||||||
|
|
||||||
def get_descriptors(self):
|
def get_descriptors(self):
|
||||||
descriptors = dict(actions=dict(), traits=dict())
|
descriptors = dict(actions=dict(), traits=dict())
|
||||||
for k, v in self.turtle.__dict__.items():
|
|
||||||
if not k.startswith("_"):
|
|
||||||
descriptors["traits"][k] = TraitDescriptor(
|
|
||||||
k, inspect.getdoc(v), readable=True, writable=False
|
|
||||||
)
|
|
||||||
|
|
||||||
for m_name, member in inspect.getmembers(Turtle):
|
for m_name, member in inspect.getmembers(Turtle):
|
||||||
if m_name.startswith("_"):
|
if m_name.startswith("_"):
|
||||||
|
Loading…
Reference in New Issue
Block a user