Skip to content

Commit 240ac67

Browse files
committed
Fix lint errors.
Should be flake8 clean again now.
1 parent 29af292 commit 240ac67

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

programmer/tinyprog/__init__.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def get_ports(device_id):
8383
try:
8484
ports += [
8585
UsbPort(usb, d)
86-
for d in usb.core.find(idVendor=vid, idProduct=pid, find_all=True)
86+
for d in usb.core.find(
87+
idVendor=vid, idProduct=pid, find_all=True)
8788
if not d.is_kernel_driver_active(1)
8889
]
8990
except usb.core.USBError as e:
@@ -102,6 +103,7 @@ def get_ports(device_id):
102103
class PortError(Exception):
103104
pass
104105

106+
105107
class SerialPort(object):
106108
def __init__(self, port_name):
107109
self.port_name = port_name
@@ -141,6 +143,7 @@ def read(self, length):
141143
except serial.SerialException as e:
142144
raise PortError("Failed to read from serial port:\n%s" % str(e))
143145

146+
144147
class UsbPort(object):
145148
def __init__(self, usb, device):
146149
self.usb = usb
@@ -178,6 +181,7 @@ def read(self, length):
178181
except self.usb.core.USBError as e:
179182
raise PortError("Failed to read from USB:\n%s" % str(e))
180183

184+
181185
def _mirror_byte(b):
182186
return bit_reverse_table[to_int(b)]
183187

@@ -197,7 +201,11 @@ def __init__(self, prog):
197201

198202
def _parse_json(self, data):
199203
try:
200-
return json.loads(bytes(data).replace(b"\x00", b"").replace(b"\xff", b"").decode("utf-8"))
204+
data = bytes(data)
205+
data = data.replace(b"\x00", b"")
206+
data = data.replace(b"\xff", b"")
207+
data = data.decode("utf-8")
208+
return json.loads(data)
201209
except BaseException:
202210
return None
203211

@@ -251,7 +259,8 @@ def userdata_addr_range(self):
251259

252260
def _get_addr_range(self, name):
253261
# get the bootmeta's addrmap or fallback to the root's addrmap.
254-
addr_map = self.root.get(u"bootmeta", {}).get(u"addrmap", self.root.get(u"addrmap", None))
262+
addr_map = self.root.get(u"bootmeta", {}).get(
263+
u"addrmap", self.root.get(u"addrmap", None))
255264
if addr_map is None:
256265
raise Exception("Missing address map from device metadata")
257266
addr_str = addr_map.get(name, None)

programmer/tinyprog/__main__.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
#!/usr/bin/env python
2+
3+
from __future__ import print_function
4+
15
import sys
26
import argparse
37
import json
@@ -355,7 +359,8 @@ def parse_int(str_value):
355359

356360
if args.update_bootloader:
357361
boards_needing_update = (
358-
check_for_wrong_tinyfpga_bx_vidpid() + check_for_new_bootloader())
362+
check_for_wrong_tinyfpga_bx_vidpid()
363+
+ check_for_new_bootloader())
359364

360365
if len(boards_needing_update) == 0:
361366
print("""\
@@ -365,7 +370,8 @@ def parse_int(str_value):
365370
perform_bootloader_update(port)
366371

367372
# program the flash memory
368-
if (args.program is not None) or (args.program_userdata is not None) or (
373+
if (args.program is not None) or (
374+
args.program_userdata is not None) or (
369375
args.program_image is not None):
370376
boot_fpga = False
371377

@@ -422,7 +428,8 @@ def progress(info):
422428
sys.exit(1)
423429

424430
if check_if_overwrite_bootloader(
425-
addr, len(bitstream), fpga.meta.userdata_addr_range()):
431+
addr, len(bitstream),
432+
fpga.meta.userdata_addr_range()):
426433
boot_fpga = True
427434
print(" Programming at addr {:06x}".format(addr))
428435
if not fpga.program_bitstream(addr, bitstream):

programmer/tox.ini

+3-2
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ commands =
1717
check-manifest --ignore tox.ini,tinyprog/full_version.py
1818
python setup.py check -m -s
1919
python check_doctests.py
20-
flake8 --exclude=data_tables.py setup.py tinyprog
20+
flake8 setup.py tinyprog
2121
python setup.py install
2222
tinyprog --help
2323
tinyprog --version
2424

2525
[flake8]
26-
exclude = .tox,*.egg,build,data
26+
exclude = .tox,*.egg,build,data,data_tables.py
2727
select = E,W,F
28+
ignore=W503

0 commit comments

Comments
 (0)