diff --git a/memfs.py b/memfs.py index 428063633..187a58ab1 100755 --- a/memfs.py +++ b/memfs.py @@ -42,10 +42,8 @@ CHUNK = 16 * 1024 * 1024 # chunk size in bytes try: str(b"\x23\x20", "ascii") ascii = lambda x: str(x, "ascii") # Python 3 - encode = lambda x: x.encode() except: ascii = lambda x: str(x) # Python 2 - encode = lambda x: x def get_outfile_name(base, count): @@ -93,7 +91,7 @@ for directory in dirs: FILES[name] = fname SIZES[name] = os.path.getsize(full) - buffer.write(encode("const unsigned char %s[] = {" % (name,))) + buffer.write("const unsigned char %s[] = {" % (name,)) with open(full, "rb") as f: i = 0 @@ -107,14 +105,12 @@ for directory in dirs: # e.g. 23 -> 0x23 for n in range(0, len(contents_hex), 2): twoChars = ascii(contents_hex[n : n + 2]) - - buffer.write(encode("0x%s," % (twoChars,))) - + buffer.write("0x%s," % (twoChars,)) i += 1 if (i % 20) == 0: - buffer.write(encode("\n")) + buffer.write("\n") - buffer.write(encode("};\n")) + buffer.write("};\n") if buffer.tell() >= CHUNK: buffer.close() buffer = None