mirror of https://github.com/ecmwf/eccodes.git
MEMFS: no need to use binary mode for output
This commit is contained in:
parent
04f9599862
commit
149a6fcc0d
10
memfs.py
10
memfs.py
|
@ -69,7 +69,7 @@ for directory in dirs:
|
||||||
fcount += 1
|
fcount += 1
|
||||||
opath = get_outfile_name(output_file_base, fcount)
|
opath = get_outfile_name(output_file_base, fcount)
|
||||||
print("MEMFS: Generating output:", opath)
|
print("MEMFS: Generating output:", opath)
|
||||||
buffer = open(opath, 'wb')
|
buffer = open(opath, "w")
|
||||||
|
|
||||||
full = "%s/%s" % (dirpath, name)
|
full = "%s/%s" % (dirpath, name)
|
||||||
_, ext = os.path.splitext(full)
|
_, ext = os.path.splitext(full)
|
||||||
|
@ -89,7 +89,7 @@ for directory in dirs:
|
||||||
SIZES[name] = os.path.getsize(full)
|
SIZES[name] = os.path.getsize(full)
|
||||||
|
|
||||||
txt = "const unsigned char %s[] = {" % (name,)
|
txt = "const unsigned char %s[] = {" % (name,)
|
||||||
buffer.write(txt.encode())
|
buffer.write(txt)
|
||||||
|
|
||||||
with open(full, "rb") as f:
|
with open(full, "rb") as f:
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -104,12 +104,12 @@ for directory in dirs:
|
||||||
for n in range(0, len(contents_hex), 2):
|
for n in range(0, len(contents_hex), 2):
|
||||||
twoChars = ascii(contents_hex[n : n + 2])
|
twoChars = ascii(contents_hex[n : n + 2])
|
||||||
txt = "0x%s," % (twoChars,)
|
txt = "0x%s," % (twoChars,)
|
||||||
buffer.write(txt.encode())
|
buffer.write(txt)
|
||||||
i += 1
|
i += 1
|
||||||
if (i % 20) == 0:
|
if (i % 20) == 0:
|
||||||
buffer.write("\n".encode())
|
buffer.write("\n")
|
||||||
|
|
||||||
buffer.write("};\n".encode())
|
buffer.write("};\n")
|
||||||
if buffer.tell() >= CHUNK:
|
if buffer.tell() >= CHUNK:
|
||||||
buffer.close()
|
buffer.close()
|
||||||
buffer = None
|
buffer = None
|
||||||
|
|
Loading…
Reference in New Issue