minor PEP8 cleanup (" -> ')

This commit is contained in:
Overwatch 2014-08-19 16:29:56 +02:00
parent 6416b66f6e
commit 61fb3b1044
18 changed files with 456 additions and 456 deletions

View file

@ -8,7 +8,7 @@ from . import et
prefix = et.prefix
"""
'''
===== OverTalk protocol spec =====
==== Transport layer ====
@ -26,14 +26,14 @@ Payload consists of one or more commands:
get_command = [ 0x00 | register (1) | target register (1) ]
set_command = [ 0x01 | register (1) | length (1) | value (n) ]
With a get_command the sender requests the receiver to read its own "register" and issue
a set_command that sets the sender's "target register" to that value.
With a get_command the sender requests the receiver to read its own 'register' and issue
a set_command that sets the sender's 'target register' to that value.
A set_command does what is says on the box.
"""
'''
class Transport:
"""
'''
OverTalk Transport layer implementation.
Reads data from multiple interfaces and either router frames or receives them.
@ -41,18 +41,18 @@ class Transport:
Interfaces are objects that implement methods read() (returns one byte of data as int), write(buffer, len),
and waiting property (contains number of bytes waiting).
"""
'''
def __init__(self, my_id, interfaces, def_route):
"""
'''
@param my_id OverTalk address of this Transport instance
@param interfaces a dict of interfaces keyed by their IDs
@param def_route ID of default interface for sending
"""
'''
assert my_id not in interfaces
assert def_route in interfaces
self._print = et.Output("over.com.Transport", default_suffix="\n", timestamp=True)
self._print = et.Output('over.com.Transport', default_suffix='\n', timestamp=True)
self.my_id = my_id
self.def_route = def_route
@ -61,7 +61,7 @@ class Transport:
self.destination_unknown = 0
self.incoming = None
self._print("<Cg>on-line<C/>")
self._print('<Cg>on-line<C/>')
def update(self):
self.incoming = None
@ -106,7 +106,7 @@ class Transport:
else:
interface.malformed_frames += 1
self._print("broken frame received: <Cr>%s<C/>" %(interface.rxbuffer))
self._print('broken frame received: <Cr>%s<C/>' %(interface.rxbuffer))
interface.rxbuffer = []
return False
@ -133,15 +133,15 @@ class Transport:
self.incoming = (frame[2], payload)
else:
if destination in self.interfaces:
self._print("routing frame to [%d]" %(destination))
self._print('routing frame to [%d]' %(destination))
self.interfaces[destination].write(self.escape_frame(frame))
else:
if source_interface_id == self.def_route:
self.destination_unknown += 1
self._print("unknown destination <Cr>%d<C/> for frame: <Cy>%s<C/>" %(destination,
self._print('unknown destination <Cr>%d<C/> for frame: <Cy>%s<C/>' %(destination,
repr(frame)), prefix.fail)
else:
self._print("routing frame to default route [%d]" %(self.def_route))
self._print('routing frame to default route [%d]' %(self.def_route))
self.interfaces[self.def_route].write(self.escape_frame(frame))
def send_data(self, destination, data):
@ -157,7 +157,7 @@ class Transport:
s.write(frame)
class TTL_Interface:
def __init__(self, interface="/dev/ttyUSB0", baudrate=57600):
def __init__(self, interface='/dev/ttyUSB0', baudrate=57600):
try:
self.s = serial.Serial(interface, baudrate, timeout=1)
except serial.serialutil.SerialException:
@ -184,7 +184,7 @@ class TTL_Interface:
return 0
def write(self, data):
print("Sending:", ''.join([hex(x)[2:].zfill(2) for x in data]))
print('Sending:', ''.join([hex(x)[2:].zfill(2) for x in data]))
if self.s:
self.s.write(bytes(data))