From 31418a90da67a1bcd1af0a39f33e8ecc5cdd2d49 Mon Sep 17 00:00:00 2001 From: "Juan J. Martinez" Date: Tue, 15 Feb 2022 23:28:50 +0000 Subject: Use black for formatting --- tools/hdoc.py | 75 ++++++++++++++------ tools/map.py | 154 ++++++++++++++++++++++++++++------------- tools/mkdeps.py | 51 +++++++++----- tools/pandocfilter-pygments.py | 39 ++++++----- tools/png2sprites.py | 85 +++++++++++++++-------- tools/png2tiles.py | 103 ++++++++++++++++----------- 6 files changed, 331 insertions(+), 176 deletions(-) diff --git a/tools/hdoc.py b/tools/hdoc.py index 3a32eb3..4387110 100755 --- a/tools/hdoc.py +++ b/tools/hdoc.py @@ -17,29 +17,45 @@ RE_SECDOC = re.compile("//\s?(.*\n)") def main(): - parser = ArgumentParser(description="Include docs to markdown", - epilog="Copyright (C) 2020 Juan J Martinez ", - ) - - parser.add_argument("--version", action="version", - version="%(prog)s " + __version__) - parser.add_argument("--doc-version", dest="docver", default=None, - help="Use this as version instead of git tag/commit") - parser.add_argument("--header", dest="header", default=None, - help="Add this file at the begining of the document") - parser.add_argument("--footer", dest="footer", default=None, - help="Add this file at the end of the document") + parser = ArgumentParser( + description="Include docs to markdown", + epilog="Copyright (C) 2020 Juan J Martinez ", + ) + + parser.add_argument( + "--version", action="version", version="%(prog)s " + __version__ + ) + parser.add_argument( + "--doc-version", + dest="docver", + default=None, + help="Use this as version instead of git tag/commit", + ) + parser.add_argument( + "--header", + dest="header", + default=None, + help="Add this file at the begining of the document", + ) + parser.add_argument( + "--footer", + dest="footer", + default=None, + help="Add this file at the end of the document", + ) parser.add_argument("title", help="Title of the resulting document") args = parser.parse_args() if args.docver is None: - proc = Popen(["git", "describe", "--abbrev=0", "--tags"], - stdout=PIPE, stderr=PIPE) + proc = Popen( + ["git", "describe", "--abbrev=0", "--tags"], stdout=PIPE, stderr=PIPE + ) out, err = proc.communicate() if proc.returncode != 0: - proc = Popen(["git", "rev-parse", "--short", "HEAD"], - stdout=PIPE, stderr=PIPE) + proc = Popen( + ["git", "rev-parse", "--short", "HEAD"], stdout=PIPE, stderr=PIPE + ) out, err = proc.communicate() out = b"git-" + out @@ -117,14 +133,23 @@ def main(): g = RE_DOC.match(l) if g: doc += g.group(1) - ref[name] = {"name": name, "anchor": anchor, - "fn": fn, "doc": doc, "section": section} - - print("""\ + ref[name] = { + "name": name, + "anchor": anchor, + "fn": fn, + "doc": doc, + "section": section, + } + + print( + """\ --- title: '{title}' subtitle: 'Version {version}' -...""".format(title=args.title, version=docver)) +...""".format( + title=args.title, version=docver + ) + ) if args.header: with open(args.header, "rt") as fd: @@ -139,14 +164,18 @@ subtitle: 'Version {version}' if csec in sections: print(sections[csec]) - print("""\ + print( + """\ ### {name} ```c {fn} ``` {doc} -""".format(**v)) +""".format( + **v + ) + ) if args.footer: with open(args.footer, "rt") as fd: diff --git a/tools/map.py b/tools/map.py index 368a41a..13f676a 100755 --- a/tools/map.py +++ b/tools/map.py @@ -75,34 +75,71 @@ def get_property(obj, name, default): def main(): - parser = ArgumentParser(description="Map importer", - epilog="Copyright (C) 2020 Juan J Martinez ", - ) + parser = ArgumentParser( + description="Map importer", + epilog="Copyright (C) 2020 Juan J Martinez ", + ) parser.add_argument( - "--version", action="version", version="%(prog)s " + __version__) + "--version", action="version", version="%(prog)s " + __version__ + ) parser.add_argument( - "--room-width", dest="rw", default=DEF_ROOM_WIDTH, type=int, - help="room width (default: %s)" % DEF_ROOM_WIDTH) + "--room-width", + dest="rw", + default=DEF_ROOM_WIDTH, + type=int, + help="room width (default: %s)" % DEF_ROOM_WIDTH, + ) parser.add_argument( - "--room-height", dest="rh", default=DEF_ROOM_HEIGHT, type=int, - help="room height (default: %s)" % DEF_ROOM_HEIGHT) - parser.add_argument("--max-ents", dest="max_ents", default=0, type=int, - help="max entities per room (default: unlimited)") - parser.add_argument("--max-bytes", dest="max_bytes", default=0, type=int, - help="max bytes per room (default: unlimited)") - parser.add_argument("-b", dest="bin", action="store_true", - help="output binary data (default: C code)") - parser.add_argument("-d", dest="dir", default=".", type=str, - help="directory to generate the bin files (default: .)") - parser.add_argument("-c", dest="conf", default=DEF_MAP_CONF, type=str, - help="JSON configuration file (default: %s)" % DEF_MAP_CONF) - parser.add_argument("--aplib", dest="aplib", action="store_true", - help="APLIB compressed") - parser.add_argument("-r", dest="reverse", action="store_true", - help="Reverse map order") - parser.add_argument("-q", dest="quiet", action="store_true", - help="Don't output stats on stderr") + "--room-height", + dest="rh", + default=DEF_ROOM_HEIGHT, + type=int, + help="room height (default: %s)" % DEF_ROOM_HEIGHT, + ) + parser.add_argument( + "--max-ents", + dest="max_ents", + default=0, + type=int, + help="max entities per room (default: unlimited)", + ) + parser.add_argument( + "--max-bytes", + dest="max_bytes", + default=0, + type=int, + help="max bytes per room (default: unlimited)", + ) + parser.add_argument( + "-b", + dest="bin", + action="store_true", + help="output binary data (default: C code)", + ) + parser.add_argument( + "-d", + dest="dir", + default=".", + type=str, + help="directory to generate the bin files (default: .)", + ) + parser.add_argument( + "-c", + dest="conf", + default=DEF_MAP_CONF, + type=str, + help="JSON configuration file (default: %s)" % DEF_MAP_CONF, + ) + parser.add_argument( + "--aplib", dest="aplib", action="store_true", help="APLIB compressed" + ) + parser.add_argument( + "-r", dest="reverse", action="store_true", help="Reverse map order" + ) + parser.add_argument( + "-q", dest="quiet", action="store_true", help="Don't output stats on stderr" + ) parser.add_argument("map_json", help="Map to import") parser.add_argument("id", help="variable name") @@ -162,7 +199,7 @@ def main(): # track empty maps empty = [] for i, block in enumerate(out): - if all([byte == 0xff for byte in block]): + if all([byte == 0xFF for byte in block]): empty.append(i) if args.aplib: @@ -181,7 +218,7 @@ def main(): size = len(out[i]) # ents size placeholder 0 - out[i] = [size & 0xff, size >> 8, 0] + out[i] + out[i] = [size & 0xFF, size >> 8, 0] + out[i] entities_layer = find_name(data["layers"], "Entities") if len(entities_layer): @@ -209,8 +246,9 @@ def main(): for obj in objs: name = obj["name"].lower() - m = ((obj["x"] // tilewidth) // args.rw) \ - + (((obj["y"] // tileheight) // args.rh) * (mw // args.rw)) + m = ((obj["x"] // tilewidth) // args.rw) + ( + ((obj["y"] // tileheight) // args.rh) * (mw // args.rw) + ) x = obj["x"] % (args.rw * tilewidth) y = obj["y"] % (args.rh * tileheight) @@ -259,14 +297,17 @@ def main(): if args.max_ents: for i, weight in map_ents_w.items(): if weight > args.max_ents: - parser.error("map %i has %d entities, max is %d" % - (i, weight, args.max_ents)) + parser.error( + "map %i has %d entities, max is %d" % (i, weight, args.max_ents) + ) if args.max_bytes: for i, byts in map_ents_bytes.items(): if byts > args.max_bytes: - parser.error("map %i entities are %d bytes, max is %d" % - (i, byts, args.max_bytes)) + parser.error( + "map %i entities are %d bytes, max is %d" + % (i, byts, args.max_bytes) + ) # append the entities to the map data for i in range(len(out)): @@ -276,7 +317,7 @@ def main(): out[i].extend(map_ents[i]) out[i][2] += len(map_ents[i]) # terminator - out[i].append(0xff) + out[i].append(0xFF) out[i][2] += 1 if args.reverse: @@ -295,10 +336,17 @@ def main(): if not args.quiet: screen_with_data = len(out) - len(empty) total_bytes = sum(len(b) if b else 0 for b in out) - print("%s: %s (%d screens, %d bytes, %.2f bytes avg)" % ( - path.basename(sys.argv[0]), args.id, - screen_with_data, total_bytes, total_bytes / screen_with_data), - file=sys.stderr) + print( + "%s: %s (%d screens, %d bytes, %.2f bytes avg)" + % ( + path.basename(sys.argv[0]), + args.id, + screen_with_data, + total_bytes, + total_bytes / screen_with_data, + ), + file=sys.stderr, + ) return print("#ifndef _%s_H" % args.id.upper()) @@ -318,16 +366,19 @@ def main(): for part in range(0, len(block), args.rw // 2): if data_out_part: data_out_part += ",\n" - data_out_part += ', '.join( - ["0x%02x" % byte for byte in block[part: part + args.rw // 2]]) - data_out += "const unsigned char %s_%d[%d] = {\n" % ( - args.id, i, len(block)) + data_out_part += ", ".join( + ["0x%02x" % byte for byte in block[part : part + args.rw // 2]] + ) + data_out += "const unsigned char %s_%d[%d] = {\n" % (args.id, i, len(block)) data_out += data_out_part + "\n};\n" data_out += "const unsigned char * const %s[%d] = { " % (args.id, len(out)) - data_out += ', '.join( - ["%s_%d" % (args.id, - i) if i not in empty else "(unsigned char *)0" for i in range(len(out))]) + data_out += ", ".join( + [ + "%s_%d" % (args.id, i) if i not in empty else "(unsigned char *)0" + for i in range(len(out)) + ] + ) data_out += " };\n" print(data_out) @@ -340,10 +391,17 @@ def main(): if not args.quiet: screen_with_data = len(out) - len(empty) total_bytes = sum(len(b) if b else 0 for b in out) - print("%s: %s (%d screens, %d bytes, %.2f bytes avg)" % ( - path.basename(sys.argv[0]), args.id, - screen_with_data, total_bytes, total_bytes / screen_with_data), - file=sys.stderr) + print( + "%s: %s (%d screens, %d bytes, %.2f bytes avg)" + % ( + path.basename(sys.argv[0]), + args.id, + screen_with_data, + total_bytes, + total_bytes / screen_with_data, + ), + file=sys.stderr, + ) if __name__ == "__main__": diff --git a/tools/mkdeps.py b/tools/mkdeps.py index 89df9d8..cb70555 100755 --- a/tools/mkdeps.py +++ b/tools/mkdeps.py @@ -14,23 +14,41 @@ def main(): FIX_RE = r"([^:]+:)" - parser = ArgumentParser(description="mkdeps for SDCC", - epilog="Copyright (C) 2021 Juan J Martinez ", - ) + parser = ArgumentParser( + description="mkdeps for SDCC", + epilog="Copyright (C) 2021 Juan J Martinez ", + ) parser.add_argument( - "--version", action="version", version="%(prog)s " + __version__) + "--version", action="version", version="%(prog)s " + __version__ + ) - parser.add_argument("-b", "--build-dir", dest="build", default=None, type=str, - help="Directory to build") - parser.add_argument("-I", "--include", dest="include", default=None, type=str, - help="Include directory (for multiple directories, use : as separator)") - parser.add_argument("-v", "--verbose", dest="verbose", action="store_true", - help="Enable verbose output") + parser.add_argument( + "-b", + "--build-dir", + dest="build", + default=None, + type=str, + help="Directory to build", + ) + parser.add_argument( + "-I", + "--include", + dest="include", + default=None, + type=str, + help="Include directory (for multiple directories, use : as separator)", + ) + parser.add_argument( + "-v", + "--verbose", + dest="verbose", + action="store_true", + help="Enable verbose output", + ) parser.add_argument("dir", help="Directory to scan") - parser.add_argument( - "deps", help="Dependencies file (to include in Makefile)") + parser.add_argument("deps", help="Dependencies file (to include in Makefile)") args = parser.parse_args() @@ -41,13 +59,12 @@ def main(): result = [] for d in sorted(glob.glob(os.path.join(args.dir, "*.c"))): if args.verbose: - print("running %r" % ' '.join(cmd + [d])) - out = subprocess.run(cmd + [d], stdout=subprocess.PIPE, - stderr=subprocess.PIPE) + print("running %r" % " ".join(cmd + [d])) + out = subprocess.run(cmd + [d], stdout=subprocess.PIPE, stderr=subprocess.PIPE) if out.returncode: sys.exit("Error: %s" % out.stderr) - out = out.stdout.decode('utf-8').strip("\n\r") + out = out.stdout.decode("utf-8").strip("\n\r") result.append(re.sub(FIX_RE, fix_path, out)) try: @@ -57,7 +74,7 @@ def main(): print("%r not found, will generate" % args.deps) old = None - new = '\n'.join(result) + new = "\n".join(result) if new != old: with open(args.deps, "wt") as fd: diff --git a/tools/pandocfilter-pygments.py b/tools/pandocfilter-pygments.py index ee678f8..2b4161f 100755 --- a/tools/pandocfilter-pygments.py +++ b/tools/pandocfilter-pygments.py @@ -10,28 +10,29 @@ Requires: from pandocfilters import toJSONFilter, RawBlock from pygments import highlight -from pygments.lexers import (get_lexer_by_name, guess_lexer, TextLexer) +from pygments.lexers import get_lexer_by_name, guess_lexer, TextLexer from pygments.formatters import get_formatter_by_name + def pygmentize(key, value, format, meta): - if key == 'CodeBlock': - [[ident, classes, keyvals], code] = value - lexer = None - for klass in classes: - try: - lexer = get_lexer_by_name(klass) - break - except: - pass - if lexer is None: - try: - lexer = guess_lexer(code) - except: - lexer = TextLexer() - if format == "html5": - format = "html" - return [RawBlock(format, highlight(code, lexer, get_formatter_by_name(format)))] + if key == "CodeBlock": + [[ident, classes, keyvals], code] = value + lexer = None + for klass in classes: + try: + lexer = get_lexer_by_name(klass) + break + except: + pass + if lexer is None: + try: + lexer = guess_lexer(code) + except: + lexer = TextLexer() + if format == "html5": + format = "html" + return [RawBlock(format, highlight(code, lexer, get_formatter_by_name(format)))] + if __name__ == "__main__": toJSONFilter(pygmentize) - diff --git a/tools/png2sprites.py b/tools/png2sprites.py index af9b83e..7528fae 100755 --- a/tools/png2sprites.py +++ b/tools/png2sprites.py @@ -35,32 +35,50 @@ TRANS = (28, 28, 28) def to_hex_list_str(src): out = "" for i in range(0, len(src), 8): - out += ', '.join(["0x%02x" % b for b in src[i:i + 8]]) + ',\n' + out += ", ".join(["0x%02x" % b for b in src[i : i + 8]]) + ",\n" return out def to_hex_list_str_asm(src): out = "" for i in range(0, len(src), 8): - out += '\tdb ' + ', '.join(["#%02x" % b for b in src[i:i + 8]]) - out += '\n' + out += "\tdb " + ", ".join(["#%02x" % b for b in src[i : i + 8]]) + out += "\n" return out def main(): - parser = ArgumentParser(description="PNG to MSX sprites", - epilog="Copyright (C) 2019 Juan J Martinez " - ) + parser = ArgumentParser( + description="PNG to MSX sprites", + epilog="Copyright (C) 2019 Juan J Martinez ", + ) parser.add_argument( - "--version", action="version", version="%(prog)s " + __version__) - parser.add_argument("-i", "--id", dest="id", default="sprites", type=str, - help="variable name (default: sprites)") - parser.add_argument("-a", "--asm", dest="asm", action="store_true", - help="ASM output (default: C header)") - parser.add_argument("-c", "--colors", dest="frame_colors", action="store_true", - help="include frame color as a comment") + "--version", action="version", version="%(prog)s " + __version__ + ) + parser.add_argument( + "-i", + "--id", + dest="id", + default="sprites", + type=str, + help="variable name (default: sprites)", + ) + parser.add_argument( + "-a", + "--asm", + dest="asm", + action="store_true", + help="ASM output (default: C header)", + ) + parser.add_argument( + "-c", + "--colors", + dest="frame_colors", + action="store_true", + help="include frame color as a comment", + ) parser.add_argument("image", help="image to convert") @@ -77,8 +95,10 @@ def main(): (w, h) = image.size if w % DEF_W or h % DEF_H: - parser.error("%s size is not multiple of sprite size (%s, %s)" % - (args.image, DEF_W, DEF_H)) + parser.error( + "%s size is not multiple of sprite size (%s, %s)" + % (args.image, DEF_W, DEF_H) + ) data = image.getdata() @@ -86,8 +106,9 @@ def main(): frame_colors = [] for y in range(0, h, DEF_H): for x in range(0, w, DEF_W): - tile = [data[x + i + ((y + j) * w)] - for j in range(DEF_H) for i in range(DEF_W)] + tile = [ + data[x + i + ((y + j) * w)] for j in range(DEF_H) for i in range(DEF_W) + ] cols = set([c for c in tile if c != TRANS]) if not cols: @@ -115,9 +136,10 @@ def main(): for i, frame in enumerate(out): print("%s_frame%d:" % (args.id, i)) if args.frame_colors: - print("\t; color: #%02x%02x%02x" % (frame_colors[i][0], - frame_colors[i][1], - frame_colors[i][2])) + print( + "\t; color: #%02x%02x%02x" + % (frame_colors[i][0], frame_colors[i][1], frame_colors[i][2]) + ) print(to_hex_list_str_asm(frame)) else: print("#ifndef _%s_H" % args.id.upper()) @@ -128,20 +150,25 @@ def main(): data_out = "" for i, frame in enumerate(out): if args.frame_colors: - data_out += '/* color: 0x%02x%02x%02x */\n' % (frame_colors[i][0], - frame_colors[i][1], - frame_colors[i][2]) - data_out += '{\n' + to_hex_list_str(frame) + '}' + data_out += "/* color: 0x%02x%02x%02x */\n" % ( + frame_colors[i][0], + frame_colors[i][1], + frame_colors[i][2], + ) + data_out += "{\n" + to_hex_list_str(frame) + "}" if i + 1 < len(out): - data_out += ',\n' + data_out += ",\n" print("#ifdef LOCAL") - print("const unsigned char %s[%d][%d] = {\n%s\n};\n" % ( - args.id, len(out), len(out[0]), data_out)) + print( + "const unsigned char %s[%d][%d] = {\n%s\n};\n" + % (args.id, len(out), len(out[0]), data_out) + ) print("#else\n") - print("extern const unsigned char %s[%d][%d];" % - (args.id, len(out), len(out[0]))) + print( + "extern const unsigned char %s[%d][%d];" % (args.id, len(out), len(out[0])) + ) print("#endif // LOCAL\n") print("#endif // _%s_H\n" % args.id.upper()) diff --git a/tools/png2tiles.py b/tools/png2tiles.py index dd71de8..43eb1e0 100755 --- a/tools/png2tiles.py +++ b/tools/png2tiles.py @@ -33,20 +33,20 @@ DEF_H = 8 # TOSHIBA palette MSX_COLS = [ - (255, 0, 255), - (0, 0, 0), + (255, 0, 255), + (0, 0, 0), (102, 204, 102), (136, 238, 136), - (68, 68, 221), + (68, 68, 221), (119, 119, 255), - (187, 85, 85), + (187, 85, 85), (119, 221, 221), (221, 102, 102), (255, 119, 119), - (204, 204, 85), + (204, 204, 85), (238, 238, 136), - (85, 170, 85), - (187, 85, 187), + (85, 170, 85), + (187, 85, 187), (204, 204, 204), (238, 238, 238), ] @@ -55,15 +55,15 @@ MSX_COLS = [ def to_hex_list_str(src): out = "" for i in range(0, len(src), 8): - out += ', '.join(["0x%02x" % b for b in src[i:i + 8]]) + ",\n" + out += ", ".join(["0x%02x" % b for b in src[i : i + 8]]) + ",\n" return out def to_hex_list_str_asm(src): out = "" for i in range(0, len(src), 8): - out += '\tdb ' + ', '.join(["#%02x" % b for b in src[i:i + 8]]) - out += '\n' + out += "\tdb " + ", ".join(["#%02x" % b for b in src[i : i + 8]]) + out += "\n" return out @@ -71,7 +71,7 @@ def read_image(image_name, out, color): try: image = Image.open(image_name) except IOError: - raise IOError("failed to open the image \"%s\"" % image_name) + raise IOError('failed to open the image "%s"' % image_name) if image.mode != "RGB": raise Exception("not a RGB image") @@ -79,8 +79,9 @@ def read_image(image_name, out, color): (w, h) = image.size if w % DEF_W or h % DEF_H: - raise Exception("%s size is not multiple of tile size (%s, %s)" % - (image_name, DEF_W, DEF_H)) + raise Exception( + "%s size is not multiple of tile size (%s, %s)" % (image_name, DEF_W, DEF_H) + ) data = image.getdata() @@ -89,18 +90,20 @@ def read_image(image_name, out, color): for y in range(0, h, DEF_H): for x in range(0, w, DEF_W): # tile data - tile = [data[x + i + ((y + j) * w)] - for j in range(DEF_H) for i in range(DEF_W)] + tile = [ + data[x + i + ((y + j) * w)] for j in range(DEF_H) for i in range(DEF_W) + ] # get the attibutes of the tile # FIXME: this may not be right for i in range(0, len(tile), DEF_W): - cols = list(set(tile[i:i + DEF_W])) + cols = list(set(tile[i : i + DEF_W])) if len(cols) > 2: raise Exception( - "tile %d (%d, %d) has more than two colors: %r" % ( - ntiles, x, y, cols)) + "tile %d (%d, %d) has more than two colors: %r" + % (ntiles, x, y, cols) + ) elif len(cols) == 1: cols.append(MSX_COLS[1]) @@ -108,13 +111,13 @@ def read_image(image_name, out, color): if c not in MSX_COLS: raise Exception( "%s: tile %d (%d, %d) has a color not in the" - " expected MSX palette: %r" % (os.path.basename(image_name), - ntiles, x, y, c)) + " expected MSX palette: %r" + % (os.path.basename(image_name), ntiles, x, y, c) + ) # each tile has two color attributes per row color_idx[ntiles * DEF_H + i // DEF_W] = cols - color.append( - (MSX_COLS.index(cols[1]) << 4) | MSX_COLS.index(cols[0])) + color.append((MSX_COLS.index(cols[1]) << 4) | MSX_COLS.index(cols[0])) frame = [] for i in range(0, len(tile), 8): @@ -123,8 +126,9 @@ def read_image(image_name, out, color): for k in range(8): # 0 or 1 is determined by the order in the color attributes # for that row - byte |= color_idx[ - ntiles * DEF_H + i // DEF_W].index(tile[i + k]) << p + byte |= ( + color_idx[ntiles * DEF_H + i // DEF_W].index(tile[i + k]) << p + ) p -= 1 frame.append(byte) @@ -136,18 +140,35 @@ def read_image(image_name, out, color): def main(): - parser = ArgumentParser(description="PNG to MSX tiles", - epilog="Copyright (C) 2019 Juan J Martinez ", - ) + parser = ArgumentParser( + description="PNG to MSX tiles", + epilog="Copyright (C) 2019 Juan J Martinez ", + ) parser.add_argument( - "--version", action="version", version="%(prog)s " + __version__) - parser.add_argument("-i", "--id", dest="id", default="tileset", type=str, - help="variable name (default: tileset)") - parser.add_argument("-a", "--asm", dest="asm", action="store_true", - help="ASM output (default: C header)") - parser.add_argument("--no-colors", dest="no_colors", action="store_true", - help="don't include colors") + "--version", action="version", version="%(prog)s " + __version__ + ) + parser.add_argument( + "-i", + "--id", + dest="id", + default="tileset", + type=str, + help="variable name (default: tileset)", + ) + parser.add_argument( + "-a", + "--asm", + dest="asm", + action="store_true", + help="ASM output (default: C header)", + ) + parser.add_argument( + "--no-colors", + dest="no_colors", + action="store_true", + help="don't include colors", + ) parser.add_argument("image", nargs="+", help="image or images to convert") @@ -180,20 +201,22 @@ def main(): data_out = to_hex_list_str(out) print("#ifdef LOCAL") - print("const unsigned char %s[%d] = {\n%s\n};\n" % - (args.id, len(out), data_out)) + print( + "const unsigned char %s[%d] = {\n%s\n};\n" % (args.id, len(out), data_out) + ) if not args.no_colors: color_out = to_hex_list_str(color) - print("const unsigned char %s_colors[%d] = {\n%s\n};\n" % ( - args.id, len(color), color_out)) + print( + "const unsigned char %s_colors[%d] = {\n%s\n};\n" + % (args.id, len(color), color_out) + ) print("#else\n") print("extern const unsigned char %s[%d];" % (args.id, len(out))) if not args.no_colors: - print("extern const unsigned char %s_colors[%d];" % ( - args.id, len(color))) + print("extern const unsigned char %s_colors[%d];" % (args.id, len(color))) print("#endif // LOCAL\n") print("#endif // _%s_H\n" % args.id.upper()) -- cgit v1.2.3