style: some of the suggestions from flake8 and pylint
diff --git a/serial/urlhandler/protocol_alt.py b/serial/urlhandler/protocol_alt.py
index af1646a..e33144e 100644
--- a/serial/urlhandler/protocol_alt.py
+++ b/serial/urlhandler/protocol_alt.py
@@ -16,19 +16,21 @@
# use poll based implementation on Posix (Linux):
# python -m serial.tools.miniterm alt:///dev/ttyUSB0?class=PosixPollSerial
-import serial
-
try:
import urlparse
except ImportError:
import urllib.parse as urlparse
+import serial
+
def serial_class_for_url(url):
"""extract host and port from an URL string"""
parts = urlparse.urlsplit(url)
if parts.scheme != 'alt':
- raise serial.SerialException('expected a string in the form "alt://port[?option[=value][&option[=value]]]": not starting with alt:// (%r)' % (parts.scheme,))
+ raise serial.SerialException(
+ 'expected a string in the form "alt://port[?option[=value][&option[=value]]]": '
+ 'not starting with alt:// (%r)' % (parts.scheme,))
class_name = 'Serial'
try:
for option, values in urlparse.parse_qs(parts.query, True).items():
@@ -37,7 +39,9 @@
else:
raise ValueError('unknown option: %r' % (option,))
except ValueError as e:
- raise serial.SerialException('expected a string in the form "alt://port[?option[=value][&option[=value]]]": %s' % e)
+ raise serial.SerialException(
+ 'expected a string in the form '
+ '"alt://port[?option[=value][&option[=value]]]": %s' % e)
if not hasattr(serial, class_name):
raise ValueError('unknown class: %r' % (class_name,))
cls = getattr(serial, class_name)
diff --git a/serial/urlhandler/protocol_spy.py b/serial/urlhandler/protocol_spy.py
index 55563f9..4921990 100644
--- a/serial/urlhandler/protocol_spy.py
+++ b/serial/urlhandler/protocol_spy.py
@@ -80,18 +80,21 @@
self.tx_color = '\x1b[31m'
def rx(self, data):
+ """show received data"""
if self.color:
self.output.write(self.rx_color)
self.output.write(data)
self.output.flush()
def tx(self, data):
+ """show transmitted data"""
if self.color:
self.output.write(self.tx_color)
self.output.write(data)
self.output.flush()
def control(self, name, value):
+ """(do not) show control calls"""
pass
@@ -123,6 +126,7 @@
self.output.flush()
def rx(self, data):
+ """show received data as hex dump"""
if self.color:
self.output.write(self.rx_color)
if data:
@@ -132,12 +136,14 @@
self.write_line(time.time() - self.start_time, 'RX', '<empty>')
def tx(self, data):
+ """show transmitted data as hex dump"""
if self.color:
self.output.write(self.tx_color)
for offset, row in hexdump(data):
self.write_line(time.time() - self.start_time, 'TX', '{:04X} '.format(offset), row)
def control(self, name, value):
+ """show control calls"""
if self.color:
self.output.write(self.control_color)
self.write_line(time.time() - self.start_time, name, value)
@@ -262,6 +268,6 @@
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if __name__ == '__main__':
- s = Serial(None)
- s.port = 'spy:///dev/ttyS0'
- print(s)
+ ser = Serial(None)
+ ser.port = 'spy:///dev/ttyS0'
+ print(ser)