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."""
|
||||
action = self.get_descriptors()["actions"].get(action_name)
|
||||
if action:
|
||||
self._state = DeviceLifecycleState.CLOSE
|
||||
getattr(self.turtle, action_name)(*args, **kwargs)
|
||||
self._state = DeviceLifecycleState.OPEN
|
||||
return
|
||||
else:
|
||||
raise DeviceError("No such action: `{}`".format(action_name))
|
||||
@ -59,11 +57,6 @@ class TurtleDevice(SynchronyDevice):
|
||||
|
||||
def get_descriptors(self):
|
||||
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):
|
||||
if m_name.startswith("_"):
|
||||
|
Loading…
Reference in New Issue
Block a user