Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/dash in pinlabel #140

Merged
merged 1 commit into from
Aug 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions src/wireviz/wv_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,26 @@ def expand(yaml_data):
yaml_data = [yaml_data]
for e in yaml_data:
e = str(e)
if '-' in e: # list of pins
a, b = tuple(map(int, e.split('-')))
if a < b:
for x in range(a, b + 1):
output.append(x)
elif a > b:
for x in range(a, b - 1, -1):
output.append(x)
elif a == b:
output.append(a)
if '-' in e:
a, b = e.split('-', 1)
try:
a = int(a)
b = int(b)
if a < b:
for x in range(a, b + 1):
output.append(x) # ascending range
elif a > b:
for x in range(a, b - 1, -1):
output.append(x) # descending range
else: # a == b
output.append(a) # range of length 1
except:
output.append(e) # '-' was not a delimiter between two ints, pass e through unchanged
else:
try:
x = int(e)
x = int(e) # single int
except Exception:
x = e
x = e # string
output.append(x)
return output

Expand Down