Skip to content

Commit 16172b0

Browse files
authored
Pep8 improvements
1 parent 2a5fdd5 commit 16172b0

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

usb_arm/__init__.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Maplin USB Robot arm control.
2-
Usage -
2+
Usage -
33
>>> import usb_arm
44
>>> arm = usb_arm.Arm()
55
>>> arm.move(usb_arm.OpenGrips)
@@ -31,15 +31,15 @@ def __or__(self, other):
3131
return BitPattern(self.arm | other.arm,
3232
self.base | other.base,
3333
self.led | other.led)
34-
34+
3535
def __eq__(self, other):
3636
return self.arm == other.arm and self.base == other.base and self.led == other.led
3737

3838
def __repr__(self):
3939
return "<BitPattern arm:%s base:%s led:%s>" % (self.arm, self.base, self.led)
4040

4141
def __str__(self):
42-
return self.__repr__()
42+
return self.__repr__()
4343

4444
GripsClose = BitPattern(1, 0, 0)
4545
CloseGrips = GripsClose
@@ -75,42 +75,44 @@ def safe_tell(self, fn):
7575
case of an exception"""
7676
try:
7777
fn()
78-
except:
78+
except Exception:
7979
self.tell(Stop)
8080
raise
8181

8282
def move(self, pattern, time=1):
8383
"""Perform a pattern move with timing and stop"""
8484
try:
85-
self.tell(pattern)
86-
sleep(time)
85+
delf.tell(pattern)
86+
sleep(time)
8787
finally:
88-
self.tell(Stop)
88+
self.tell(Stop)
8989

9090
def doActions(self, actions):
9191
"""Params: List of actions - each is a list/tuple of BitPattern and time
9292
(defaulting to 1 if not set)"""
93-
#Validate
93+
# Validate
9494
for action in actions:
9595
if not 1 <= len(action) <= 2:
9696
raise ValueError("Wrong number of parameters in action %s" %
9797
(repr(action)))
9898
if not isinstance(action[0], BitPattern):
9999
raise ValueError("Not a valid action")
100-
#Do
100+
# Do
101101
for action in actions:
102102
if len(action) == 2:
103103
time = action[1]
104104
else:
105105
time = 1
106106
self.move(action[0], time)
107107

108+
108109
def makeGrabAndMove(baseDir):
109-
return [[CloseGrips, 1.1],
110-
[ShoulderUp | ElbowUp | WristDown | baseDir],
111-
[baseDir, 8.5],
112-
[ShoulderDown | ElbowDown | WristUp | baseDir],
113-
[OpenGrips]]
110+
return [[CloseGrips, 1.1],
111+
[ShoulderUp | ElbowUp | WristDown | baseDir],
112+
[baseDir, 8.5],
113+
[ShoulderDown | ElbowDown | WristUp | baseDir],
114+
[OpenGrips]]
115+
114116

115117
blink = [[LedOn, 0.5], [Stop, 0.5]] * 3
116118
block_left = makeGrabAndMove(BaseClockWise) + blink

0 commit comments

Comments
 (0)