Remove unneeded semicolons and parentheses from Python files

This commit is contained in:
John Bampton 2020-12-13 02:53:21 +10:00 committed by Abdelatif Guettouche
parent e4cddb169a
commit db0b595b4b
2 changed files with 15 additions and 13 deletions

View File

@ -9,9 +9,9 @@ while len(s) < 11520:
s += "1"
print("Sending to %s" % sys.argv[1])
while(True):
f.write(s);
f.flush();
while True:
f.write(s)
f.flush()
#for i in range(len(s)):
# f.write(s[i])
# f.flush()

View File

@ -19,28 +19,28 @@ def get_palette(img, maxcolors = 255):
def write_palette(outfile, palette):
'''Write the palette (normal and highlight) to the output file.'''
outfile.write('static const NXWidgets::nxwidget_pixel_t palette[BITMAP_PALETTESIZE] =\n');
outfile.write('static const NXWidgets::nxwidget_pixel_t palette[BITMAP_PALETTESIZE] =\n')
outfile.write('{\n')
for i in range(0, len(palette), 4):
outfile.write(' ');
outfile.write(' ')
for r, g, b in palette[i:i+4]:
outfile.write('MKRGB(%3d,%3d,%3d), ' % (r, g, b))
outfile.write('\n');
outfile.write('\n')
outfile.write('};\n\n')
outfile.write('static const NXWidgets::nxwidget_pixel_t hilight_palette[BITMAP_PALETTESIZE] =\n');
outfile.write('static const NXWidgets::nxwidget_pixel_t hilight_palette[BITMAP_PALETTESIZE] =\n')
outfile.write('{\n')
for i in range(0, len(palette), 4):
outfile.write(' ');
outfile.write(' ')
for r, g, b in palette[i:i+4]:
r = min(255, r + 50)
g = min(255, g + 50)
b = min(255, b + 50)
outfile.write('MKRGB(%3d,%3d,%3d), ' % (r, g, b))
outfile.write('\n');
outfile.write('\n')
outfile.write('};\n\n')
@ -54,7 +54,8 @@ def quantize(color, palette):
def distance(color2):
return sum([(a - b)**2 for a, b in zip(color, color2)])
return palette.index(min(palette, key = distance));
return palette.index(min(palette, key = distance))
def encode_row(img, palette, y):
'''RLE-encode one row of image data.'''
@ -81,8 +82,8 @@ def encode_row(img, palette, y):
def write_image(outfile, img, palette):
'''Write the image contents to the output file.'''
outfile.write('static const NXWidgets::SRlePaletteBitmapEntry bitmap[] =\n');
outfile.write('{\n');
outfile.write('static const NXWidgets::SRlePaletteBitmapEntry bitmap[] =\n')
outfile.write('{\n')
for y in range(0, img.size[1]):
entries = encode_row(img, palette, y)
@ -97,7 +98,8 @@ def write_image(outfile, img, palette):
row += ' ' * (73 - len(row))
outfile.write(' ' + row + '/* Row %d */\n' % y)
outfile.write('};\n\n');
outfile.write('};\n\n')
def write_descriptor(outfile, name):
'''Write the public descriptor structure for the image.'''