style: some of the suggestions from flake8
diff --git a/serial/__init__.py b/serial/__init__.py
index 78bdd19..4f222f3 100644
--- a/serial/__init__.py
+++ b/serial/__init__.py
@@ -23,7 +23,7 @@
if os.name == 'nt': # sys.platform == 'win32':
from serial.serialwin32 import Serial
elif os.name == 'posix':
- from serial.serialposix import Serial, PosixPollSerial, VTIMESerial # noqa
+ from serial.serialposix import Serial, PosixPollSerial, VTIMESerial # noqa
elif os.name == 'java':
from serial.serialjava import Serial
else:
diff --git a/serial/rfc2217.py b/serial/rfc2217.py
index 82cb066..e56eacf 100644
--- a/serial/rfc2217.py
+++ b/serial/rfc2217.py
@@ -82,11 +82,11 @@
# map log level names to constants. used in from_url()
LOGGER_LEVELS = {
- 'debug': logging.DEBUG,
- 'info': logging.INFO,
- 'warning': logging.WARNING,
- 'error': logging.ERROR,
- }
+ 'debug': logging.DEBUG,
+ 'info': logging.INFO,
+ 'warning': logging.WARNING,
+ 'error': logging.ERROR,
+}
# telnet protocol characters
@@ -429,13 +429,13 @@
'datasize': TelnetSubnegotiation(self, 'datasize', SET_DATASIZE, SERVER_SET_DATASIZE),
'parity': TelnetSubnegotiation(self, 'parity', SET_PARITY, SERVER_SET_PARITY),
'stopsize': TelnetSubnegotiation(self, 'stopsize', SET_STOPSIZE, SERVER_SET_STOPSIZE),
- }
+ }
# There are more subnegotiation objects, combine all in one dictionary
# for easy access
self._rfc2217_options = {
'purge': TelnetSubnegotiation(self, 'purge', PURGE_DATA, SERVER_PURGE_DATA),
'control': TelnetSubnegotiation(self, 'control', SET_CONTROL, SERVER_SET_CONTROL),
- }
+ }
self._rfc2217_options.update(self._rfc2217_port_settings)
# cache for line and modem states that the server sends to us
self._linestate = 0
@@ -931,7 +931,7 @@
TelnetOption(self, 'they-BINARY', BINARY, DO, DONT, WILL, WONT, REQUESTED),
TelnetOption(self, 'we-RFC2217', COM_PORT_OPTION, WILL, WONT, DO, DONT, REQUESTED, self._client_ok),
TelnetOption(self, 'they-RFC2217', COM_PORT_OPTION, DO, DONT, WILL, WONT, INACTIVE, self._client_ok),
- ]
+ ]
# negotiate Telnet/RFC2217 -> send initial requests
if self.logger:
@@ -994,9 +994,8 @@
if modemstate != self.last_modemstate or force_notification:
if (self._client_is_rfc2217 and (modemstate & self.modemstate_mask)) or force_notification:
self.rfc2217SendSubnegotiation(
- SERVER_NOTIFY_MODEMSTATE,
- to_bytes([modemstate & self.modemstate_mask])
- )
+ SERVER_NOTIFY_MODEMSTATE,
+ to_bytes([modemstate & self.modemstate_mask]))
if self.logger:
self.logger.info("NOTIFY_MODEMSTATE: %s" % (modemstate,))
# save last state, but forget about deltas.
@@ -1154,9 +1153,8 @@
if self.logger:
self.logger.info("%s parity: %s" % ('set' if parity else 'get', self.serial.parity))
self.rfc2217SendSubnegotiation(
- SERVER_SET_PARITY,
- struct.pack(b"!B", RFC2217_PARITY_MAP[self.serial.parity])
- )
+ SERVER_SET_PARITY,
+ struct.pack(b"!B", RFC2217_PARITY_MAP[self.serial.parity]))
elif suboption[1:2] == SET_STOPSIZE:
backup = self.serial.stopbits
try:
@@ -1171,9 +1169,8 @@
if self.logger:
self.logger.info("%s stop bits: %s" % ('set' if stopbits else 'get', self.serial.stopbits))
self.rfc2217SendSubnegotiation(
- SERVER_SET_STOPSIZE,
- struct.pack(b"!B", RFC2217_STOPBIT_MAP[self.serial.stopbits])
- )
+ SERVER_SET_STOPSIZE,
+ struct.pack(b"!B", RFC2217_STOPBIT_MAP[self.serial.stopbits]))
elif suboption[1:2] == SET_CONTROL:
if suboption[2:3] == SET_CONTROL_REQ_FLOW_SETTING:
if self.serial.xonxoff:
diff --git a/serial/serialcli.py b/serial/serialcli.py
index 16af67a..1873a00 100644
--- a/serial/serialcli.py
+++ b/serial/serialcli.py
@@ -23,11 +23,12 @@
def as_byte_array(string):
return sab([ord(x) for x in string]) # XXX will require adaption when run with a 3.x compatible IronPython
+
class Serial(SerialBase):
"""Serial port implementation for .NET/Mono."""
BAUDRATES = (50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
- 9600, 19200, 38400, 57600, 115200)
+ 9600, 19200, 38400, 57600, 115200)
def open(self):
"""\
@@ -69,7 +70,7 @@
if self._timeout is None:
self._port_handle.ReadTimeout = System.IO.Ports.SerialPort.InfiniteTimeout
else:
- self._port_handle.ReadTimeout = int(self._timeout*1000)
+ self._port_handle.ReadTimeout = int(self._timeout * 1000)
# if self._timeout != 0 and self._interCharTimeout is not None:
# timeouts = (int(self._interCharTimeout * 1000),) + timeouts[1:]
@@ -77,8 +78,7 @@
if self._write_timeout is None:
self._port_handle.WriteTimeout = System.IO.Ports.SerialPort.InfiniteTimeout
else:
- self._port_handle.WriteTimeout = int(self._write_timeout*1000)
-
+ self._port_handle.WriteTimeout = int(self._write_timeout * 1000)
# Setup the connection info.
try:
@@ -88,46 +88,46 @@
raise ValueError(str(e))
if self._bytesize == FIVEBITS:
- self._port_handle.DataBits = 5
+ self._port_handle.DataBits = 5
elif self._bytesize == SIXBITS:
- self._port_handle.DataBits = 6
+ self._port_handle.DataBits = 6
elif self._bytesize == SEVENBITS:
- self._port_handle.DataBits = 7
+ self._port_handle.DataBits = 7
elif self._bytesize == EIGHTBITS:
- self._port_handle.DataBits = 8
+ self._port_handle.DataBits = 8
else:
raise ValueError("Unsupported number of data bits: %r" % self._bytesize)
if self._parity == PARITY_NONE:
- self._port_handle.Parity = getattr(System.IO.Ports.Parity, 'None') # reserved keyword in Py3k
+ self._port_handle.Parity = getattr(System.IO.Ports.Parity, 'None') # reserved keyword in Py3k
elif self._parity == PARITY_EVEN:
- self._port_handle.Parity = System.IO.Ports.Parity.Even
+ self._port_handle.Parity = System.IO.Ports.Parity.Even
elif self._parity == PARITY_ODD:
- self._port_handle.Parity = System.IO.Ports.Parity.Odd
+ self._port_handle.Parity = System.IO.Ports.Parity.Odd
elif self._parity == PARITY_MARK:
- self._port_handle.Parity = System.IO.Ports.Parity.Mark
+ self._port_handle.Parity = System.IO.Ports.Parity.Mark
elif self._parity == PARITY_SPACE:
- self._port_handle.Parity = System.IO.Ports.Parity.Space
+ self._port_handle.Parity = System.IO.Ports.Parity.Space
else:
raise ValueError("Unsupported parity mode: %r" % self._parity)
if self._stopbits == STOPBITS_ONE:
- self._port_handle.StopBits = System.IO.Ports.StopBits.One
+ self._port_handle.StopBits = System.IO.Ports.StopBits.One
elif self._stopbits == STOPBITS_ONE_POINT_FIVE:
- self._port_handle.StopBits = System.IO.Ports.StopBits.OnePointFive
+ self._port_handle.StopBits = System.IO.Ports.StopBits.OnePointFive
elif self._stopbits == STOPBITS_TWO:
- self._port_handle.StopBits = System.IO.Ports.StopBits.Two
+ self._port_handle.StopBits = System.IO.Ports.StopBits.Two
else:
raise ValueError("Unsupported number of stop bits: %r" % self._stopbits)
if self._rtscts and self._xonxoff:
- self._port_handle.Handshake = System.IO.Ports.Handshake.RequestToSendXOnXOff
+ self._port_handle.Handshake = System.IO.Ports.Handshake.RequestToSendXOnXOff
elif self._rtscts:
- self._port_handle.Handshake = System.IO.Ports.Handshake.RequestToSend
+ self._port_handle.Handshake = System.IO.Ports.Handshake.RequestToSend
elif self._xonxoff:
- self._port_handle.Handshake = System.IO.Ports.Handshake.XOnXOff
+ self._port_handle.Handshake = System.IO.Ports.Handshake.XOnXOff
else:
- self._port_handle.Handshake = getattr(System.IO.Ports.Handshake, 'None') # reserved keyword in Py3k
+ self._port_handle.Handshake = getattr(System.IO.Ports.Handshake, 'None') # reserved keyword in Py3k
#~ def __del__(self):
#~ self.close()
@@ -242,7 +242,7 @@
if not self._port_handle:
raise portNotOpenError
#~ return self._port_handle.XXX
- return False #XXX an error would be better
+ return False # XXX an error would be better
@property
def cd(self):