Skip to content

Commit 2347133

Browse files
committed
fix line length problems, remove unneeded else statements
1 parent 36bd875 commit 2347133

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

adafruit_rockblock.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,27 +67,24 @@ def _uart_xfer(self, cmd):
6767
resp = []
6868
line = self._uart.readline()
6969
if line is None:
70-
# print("No response from Modem")
70+
# No response from Modem
7171
return None
72-
else:
72+
resp.append(line)
73+
while not any(EOM in line for EOM in (b"OK\r\n", b"ERROR\r\n")):
74+
line = self._uart.readline()
7375
resp.append(line)
74-
while not any(EOM in line for EOM in (b"OK\r\n", b"ERROR\r\n")):
75-
line = self._uart.readline()
76-
resp.append(line)
7776

78-
self._uart.reset_input_buffer()
77+
self._uart.reset_input_buffer()
7978

80-
return tuple(resp)
79+
return tuple(resp)
8180

8281
def reset(self):
8382
"""Perform a software reset."""
8483
if self._uart_xfer("&F0") is None: # factory defaults
8584
return False
86-
else:
87-
if self._uart_xfer("&K0") is None: # flow control off
88-
return False
89-
else:
90-
return True
85+
if self._uart_xfer("&K0") is None: # flow control off
86+
return False
87+
return True
9188

9289
def _transfer_buffer(self):
9390
"""Copy out buffer to in buffer to simulate receiving a message."""
@@ -264,8 +261,7 @@ def ring_alert(self, value=1):
264261
resp = self._uart_xfer("+SBDMTA=" + str(int(value)))
265262
if resp[-1].strip().decode() == "OK":
266263
return True
267-
else:
268-
raise RuntimeError("Error setting Ring Alert.")
264+
raise RuntimeError("Error setting Ring Alert.")
269265
else:
270266
raise ValueError(
271267
"Use 0 or False to disable Ring Alert or use 0 or True to enable Ring Alert."
@@ -302,14 +298,14 @@ def geolocation(self):
302298
The response is in the form:
303299
[<x>,<y>,<z>,<timestamp>]
304300
<x>,<y>,<z> is a geolocation grid code from an earth centered Cartesian coordinate system,
305-
using dimensions, x, y, and z, to specify location. The coordinate system is aligned such
306-
that the z-axis is aligned with the north and south poles, leaving the x-axis and y-axis
307-
to lie in the plane containing the equator. The axes are aligned such that at 0 degrees
308-
latitude and 0 degrees longitude, both y and z are zero and x is positive (x = +6376,
309-
representing the nominal earth radius in kilometres). Each dimension of the
310-
geolocation grid code is displayed in decimal form using units of kilometres.
311-
Each dimension of the geolocation grid code has a minimum value of –6376,
312-
a maximum value of +6376, and a resolution of 4.
301+
using dimensions, x, y, and z, to specify location. The coordinate system is aligned
302+
such that the z-axis is aligned with the north and south poles, leaving the x-axis
303+
and y-axis to lie in the plane containing the equator. The axes are aligned such that
304+
at 0 degrees latitude and 0 degrees longitude, both y and z are zero and
305+
x is positive (x = +6376, representing the nominal earth radius in kilometres).
306+
Each dimension of the geolocation grid code is displayed in decimal form using
307+
units of kilometres. Each dimension of the geolocation grid code has a minimum value
308+
of –6376, a maximum value of +6376, and a resolution of 4.
313309
This geolocation coordinate system is known as ECEF (acronym earth-centered, earth-fixed),
314310
also known as ECR (initialism for earth-centered rotational)
315311

0 commit comments

Comments
 (0)