Skip to content

Commit c5b1348

Browse files
Switch to python3, improve Makefile dependencies
1 parent 875c395 commit c5b1348

File tree

4 files changed

+22
-18
lines changed

4 files changed

+22
-18
lines changed

Diff for: Makefile

+8-4
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,18 @@ all: $(BIN) $(BIN:.bin=.lst) sizes/sizes.html
6565
.bin_upload:
6666
avrdude -F -V -p $(MCU_TARGET) -P $(AVR_TTY) -c $(AVR_PROGRAMMER) -b $(AVR_RATE) -U flash:w:$<
6767

68+
test/test_ws2811.cc: test/test.grb test/test.rgb
69+
70+
test/test_ws2811_bridge.cc: test/test.grb test/test.rgb
71+
6872
test/test.grb: test/make_grb.py
69-
python test/make_grb.py > test/test.grb
73+
python3 test/make_grb.py > test/test.grb
7074

7175
test/test.rgb: test/make_rgb.py
72-
python test/make_rgb.py > test/test.rgb
76+
python3 test/make_rgb.py > test/test.rgb
7377

7478
sizes/recent_sizes.json sizes/sizes.html: $(BIN)
75-
python sizes/sizes.py recent generate
79+
python3 sizes/sizes.py recent generate
7680

7781
.PHONY: history
7882
history:
@@ -83,6 +87,6 @@ sizeclean:
8387

8488
clean: sizeclean
8589
rm -f *.o *.map *.lst *.elf *.bin test/*.o test/*.map test/*.lst \
86-
test/*.elf test/*.bin .depend
90+
test/*.elf test/*.bin .depend test/test.grb test/test.rgb
8791

8892
-include .depend

Diff for: sizes/sizes.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import tempfile
1010
import datetime
1111
from argparse import ArgumentParser
12-
from urlparse import urlparse
12+
from urllib.parse import urlparse
1313

1414
template = 'sizes/sizes.template'
1515
html = 'sizes/sizes.html'
@@ -264,10 +264,10 @@ def equal_sizes(a, b):
264264
'4.5.2': { 'file.bin': 23 },
265265
'git': {...}'''
266266

267-
if a.keys() != b.keys():
267+
if list(a.keys()) != list(b.keys()):
268268
return False
269269

270-
for v, s in a.iteritems():
270+
for v, s in a.items():
271271
if v != 'git':
272272
if s != b[v]:
273273
return False
@@ -308,12 +308,12 @@ def update_recent(version):
308308
increment = False
309309
for b in binfiles():
310310
size = os.path.getsize(b)
311-
if not recent.has_key(version):
311+
if version not in recent:
312312
recent[version] = {}
313313

314314
blist = recent[version]
315315
bn = bname(b)
316-
if not blist.has_key(bn):
316+
if bn not in blist:
317317
blist[bn] = []
318318

319319
bfile = blist[bn]
@@ -398,7 +398,7 @@ def prune_boring_git_sizes(branch = None):
398398
if rev_is_interesting(h):
399399
pruned.append(s)
400400
else:
401-
print 'removing ', h
401+
print('removing ', h)
402402

403403
write_sizes(pruned, 'sizes/git_sizes.json')
404404

@@ -415,7 +415,7 @@ def update_history(version, branch = None):
415415
for s in sizes:
416416
h = s['git']['hash']
417417
# populate known hashes
418-
if s.has_key(version):
418+
if version in s:
419419
known.add(h)
420420

421421
try:
@@ -434,12 +434,12 @@ def update_history(version, branch = None):
434434

435435
rc = update_git_size(version, r, make, sizes)
436436
if not rc:
437-
print '%s ok' % r
437+
print('%s ok' % r)
438438
else:
439-
print '%s make failed (%s)' % (r, flavour)
439+
print('%s make failed (%s)' % (r, flavour))
440440
else:
441441
if not quiet:
442-
print '%s already recorded' % r
442+
print('%s already recorded' % r)
443443
finally:
444444
subprocess.call(['git', 'checkout', '-q', branch])
445445
if os.path.exists('.depend'):

Diff for: test/make_grb.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def g(x):
66

77
h = 0
88
while h < 1:
9-
print '// ' + str(h)
9+
print(('// ' + str(h)))
1010
c = colorsys.hsv_to_rgb(h, 1, 1)
11-
print g(c[1] * 255), ',', g(c[0] * 255), ',', g(c[2] * 255), ','
11+
print(g(c[1] * 255), ',', g(c[0] * 255), ',', g(c[2] * 255), ',')
1212
h += 1./240 + 1e-10

Diff for: test/make_rgb.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def g(x):
66

77
h = 0
88
while h < 1:
9-
print '// ' + str(h)
9+
print('// ' + str(h))
1010
c = colorsys.hsv_to_rgb(h, 1, 1)
11-
print g(c[0] * 255), ',', g(c[1] * 255), ',', g(c[2] * 255), ','
11+
print(g(c[0] * 255), ',', g(c[1] * 255), ',', g(c[2] * 255), ',')
1212
h += 1./240 + 1e-10

0 commit comments

Comments
 (0)