Change double quotes to single quotes for strings
This commit is contained in:
parent
1254ff23f8
commit
ee7d1ef4e3
36
src/test.py
36
src/test.py
@ -8,9 +8,9 @@ COLORS_I2C = ('BK', 'RD', 'YE', 'GN')
|
|||||||
PINOUT_SPI_DATAONLY = ('MISO','MOSI','SCK')
|
PINOUT_SPI_DATAONLY = ('MISO','MOSI','SCK')
|
||||||
|
|
||||||
# example 1
|
# example 1
|
||||||
X1 = wireviz.Node("X1", pinout=PINOUT_SERIAL, ports_right=True)
|
X1 = wireviz.Node('X1', pinout=PINOUT_SERIAL, ports_right=True)
|
||||||
X2 = wireviz.Node("X2", num_pins=6, ports_left=True)
|
X2 = wireviz.Node('X2', num_pins=6, ports_left=True)
|
||||||
W1 = wireviz.Cable("W1", show_name=True, num_wires=3, color_code="DIN", shield=True)
|
W1 = wireviz.Cable('W1', show_name=True, num_wires=3, color_code='DIN', shield=True)
|
||||||
# Option 1: define wires and shield in one line
|
# Option 1: define wires and shield in one line
|
||||||
# W1.connect(X1,(5,2,3,5),(1,2,3,'s'),X2,(1,3,2,None))
|
# W1.connect(X1,(5,2,3,5),(1,2,3,'s'),X2,(1,3,2,None))
|
||||||
# Option 2: define wires and shield separately
|
# Option 2: define wires and shield separately
|
||||||
@ -20,7 +20,7 @@ X2.loop(5,6)
|
|||||||
objects = [X1, X2, W1]
|
objects = [X1, X2, W1]
|
||||||
|
|
||||||
# example 2
|
# example 2
|
||||||
# X1 = wireviz.Node("X1", pinout=(
|
# X1 = wireviz.Node('X1', pinout=(
|
||||||
# 'GND',
|
# 'GND',
|
||||||
# '+5V',
|
# '+5V',
|
||||||
# 'SCL',
|
# 'SCL',
|
||||||
@ -30,14 +30,14 @@ objects = [X1, X2, W1]
|
|||||||
# 'SCK',
|
# 'SCK',
|
||||||
# 'N/C'
|
# 'N/C'
|
||||||
# ), ports_right=True)
|
# ), ports_right=True)
|
||||||
# X2 = wireviz.Node("X2", pinout=PINOUT_I2C, ports_left=True)
|
# X2 = wireviz.Node('X2', pinout=PINOUT_I2C, ports_left=True)
|
||||||
# X3 = wireviz.Node("X3", pinout=PINOUT_I2C, ports_left=True)
|
# X3 = wireviz.Node('X3', pinout=PINOUT_I2C, ports_left=True)
|
||||||
# X4 = wireviz.Node("X4", pinout=('GND','+12V')+PINOUT_SPI_DATAONLY, ports_left=True)
|
# X4 = wireviz.Node('X4', pinout=('GND','+12V')+PINOUT_SPI_DATAONLY, ports_left=True)
|
||||||
# X5 = wireviz.Node("X5", pinout=('GND','+12V'), ports_right=True)
|
# X5 = wireviz.Node('X5', pinout=('GND','+12V'), ports_right=True)
|
||||||
# W1 = wireviz.Cable("W1", colors=COLORS_I2C)
|
# W1 = wireviz.Cable('W1', colors=COLORS_I2C)
|
||||||
# W2 = wireviz.Cable("W2", colors=COLORS_I2C)
|
# W2 = wireviz.Cable('W2', colors=COLORS_I2C)
|
||||||
# W3 = wireviz.Cable("W3", colors=('BK','BU','OG','VT'))
|
# W3 = wireviz.Cable('W3', colors=('BK','BU','OG','VT'))
|
||||||
# W4 = wireviz.Cable("W4", colors=('BK','RD'))
|
# W4 = wireviz.Cable('W4', colors=('BK','RD'))
|
||||||
# W1.connect(X1,(1,2,3,4),'auto',X2,'auto')
|
# W1.connect(X1,(1,2,3,4),'auto',X2,'auto')
|
||||||
# W2.connect(X1,(1,2,3,4),'auto',X3,'auto')
|
# W2.connect(X1,(1,2,3,4),'auto',X3,'auto')
|
||||||
# W3.connect(X1,(1,5,6,7),'auto',X4,(1,3,4,5))
|
# W3.connect(X1,(1,5,6,7),'auto',X4,(1,3,4,5))
|
||||||
@ -45,13 +45,13 @@ objects = [X1, X2, W1]
|
|||||||
# objects = [X1, X2, X3, X4, X5, W1, W2, W3, W4]
|
# objects = [X1, X2, X3, X4, X5, W1, W2, W3, W4]
|
||||||
|
|
||||||
# example 3
|
# example 3
|
||||||
# X1 = wireviz.Node("X1", num_pins=10, ports_right=True)
|
# X1 = wireviz.Node('X1', num_pins=10, ports_right=True)
|
||||||
# X2 = wireviz.Node("X2", num_pins=10, ports_left=True)
|
# X2 = wireviz.Node('X2', num_pins=10, ports_left=True)
|
||||||
# W1 = wireviz.Cable("W1", num_wires=10, color_code="IEC")
|
# W1 = wireviz.Cable('W1', num_wires=10, color_code='IEC')
|
||||||
# W1.connect_all_straight(X1,X2)
|
# W1.connect_all_straight(X1,X2)
|
||||||
# X3 = wireviz.Node("X3", num_pins=10, ports_right=True)
|
# X3 = wireviz.Node('X3', num_pins=10, ports_right=True)
|
||||||
# X4 = wireviz.Node("X4", num_pins=10, ports_left=True)
|
# X4 = wireviz.Node('X4', num_pins=10, ports_left=True)
|
||||||
# W2 = wireviz.Cable("W2", num_wires=10, color_code="DIN")
|
# W2 = wireviz.Cable('W2', num_wires=10, color_code='DIN')
|
||||||
# W2.connect_all_straight(X3,X4)
|
# W2.connect_all_straight(X3,X4)
|
||||||
# objects = [X1, X2, W1, X3, X4, W2]
|
# objects = [X1, X2, W1, X3, X4, W2]
|
||||||
|
|
||||||
|
|||||||
@ -26,11 +26,11 @@ class Node:
|
|||||||
self.loops = []
|
self.loops = []
|
||||||
|
|
||||||
if pinout is None:
|
if pinout is None:
|
||||||
self.pinout = ("",) * num_pins
|
self.pinout = ('',) * num_pins
|
||||||
else:
|
else:
|
||||||
if num_pins is None:
|
if num_pins is None:
|
||||||
if pinout is None:
|
if pinout is None:
|
||||||
raise Exception("Must provide num_pins or pinout")
|
raise Exception('Must provide num_pins or pinout')
|
||||||
else:
|
else:
|
||||||
self.pinout = pinout
|
self.pinout = pinout
|
||||||
|
|
||||||
@ -41,16 +41,16 @@ class Node:
|
|||||||
loop_side = 'e' # east = right
|
loop_side = 'e' # east = right
|
||||||
elif self.ports_left == True and self.ports_right == True:
|
elif self.ports_left == True and self.ports_right == True:
|
||||||
if side == None:
|
if side == None:
|
||||||
raise Exception("Must specify side of loop")
|
raise Exception('Must specify side of loop')
|
||||||
else:
|
else:
|
||||||
loop_side = side
|
loop_side = side
|
||||||
self.loops.append((from_pin, to_pin, loop_side))
|
self.loops.append((from_pin, to_pin, loop_side))
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "{} = {} {}".format(self.name, len(self.pinout), self.pinout)
|
return '{} = {} {}'.format(self.name, len(self.pinout), self.pinout)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "{}".format(self.name)
|
return '{}'.format(self.name)
|
||||||
|
|
||||||
def graphviz(self):
|
def graphviz(self):
|
||||||
s = ''
|
s = ''
|
||||||
@ -104,19 +104,19 @@ class Cable:
|
|||||||
self.shield = shield
|
self.shield = shield
|
||||||
self.connections = []
|
self.connections = []
|
||||||
if color_code is None and colors is None:
|
if color_code is None and colors is None:
|
||||||
self.colors = ("",) * num_wires
|
self.colors = ('',) * num_wires
|
||||||
else:
|
else:
|
||||||
if colors is None:
|
if colors is None:
|
||||||
if num_wires is None:
|
if num_wires is None:
|
||||||
raise Exception("Unknown number of wires")
|
raise Exception('Unknown number of wires')
|
||||||
else:
|
else:
|
||||||
# TODO: Loop through colors if num_wires > len(COLOR_CODE_XXX)
|
# TODO: Loop through colors if num_wires > len(COLOR_CODE_XXX)
|
||||||
if color_code == "DIN":
|
if color_code == 'DIN':
|
||||||
self.colors = tuple(COLOR_CODE_DIN[:num_wires])
|
self.colors = tuple(COLOR_CODE_DIN[:num_wires])
|
||||||
elif color_code == "IEC":
|
elif color_code == 'IEC':
|
||||||
self.colors = tuple(COLOR_CODE_IEC[:num_wires])
|
self.colors = tuple(COLOR_CODE_IEC[:num_wires])
|
||||||
else:
|
else:
|
||||||
raise Exception("Unknown color code")
|
raise Exception('Unknown color code')
|
||||||
else:
|
else:
|
||||||
if num_wires is None:
|
if num_wires is None:
|
||||||
self.colors = colors
|
self.colors = colors
|
||||||
@ -133,7 +133,7 @@ class Cable:
|
|||||||
if to_pin == 'auto':
|
if to_pin == 'auto':
|
||||||
to_pin = tuple(x+1 for x in range(len(self.colors)))
|
to_pin = tuple(x+1 for x in range(len(self.colors)))
|
||||||
if len(from_pin) != len(to_pin):
|
if len(from_pin) != len(to_pin):
|
||||||
raise Exception("from_pin must have the same number of elements as to_pin")
|
raise Exception('from_pin must have the same number of elements as to_pin')
|
||||||
for i, x in enumerate(from_pin):
|
for i, x in enumerate(from_pin):
|
||||||
self.connections.append((from_name, from_pin[i], via[i], to_name, to_pin[i]))
|
self.connections.append((from_name, from_pin[i], via[i], to_name, to_pin[i]))
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class Cable:
|
|||||||
self.connect(from_name, 'auto', 'auto', to_name, 'auto')
|
self.connect(from_name, 'auto', 'auto', to_name, 'auto')
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "{} = {} {}\n {}".format(self.name, len(self.colors), self.colors, self.connections)
|
return '{} = {} {}\n {}'.format(self.name, len(self.colors), self.colors, self.connections)
|
||||||
|
|
||||||
def debug(self):
|
def debug(self):
|
||||||
print(self.name)
|
print(self.name)
|
||||||
@ -153,7 +153,7 @@ class Cable:
|
|||||||
else:
|
else:
|
||||||
s = '--'
|
s = '--'
|
||||||
# print(self.colors(x[2]) if i < len(self.colors) else '-')
|
# print(self.colors(x[2]) if i < len(self.colors) else '-')
|
||||||
print("{}:{} -- {}({}) -> {}:{}".format(x[0],x[1],x[2],s,x[3],x[4]))
|
print('{}:{} -- {}({}) -> {}:{}'.format(x[0],x[1],x[2],s,x[3],x[4]))
|
||||||
|
|
||||||
def graphviz(self):
|
def graphviz(self):
|
||||||
s = ''
|
s = ''
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user