mirror of https://github.com/ecmwf/eccodes.git
ECC-917: refactoring
This commit is contained in:
parent
0d2f36a164
commit
a99a8dea63
12
memfs.py
12
memfs.py
|
@ -40,11 +40,15 @@ except:
|
||||||
ascii = lambda x: str(x) # Python 2
|
ascii = lambda x: str(x) # Python 2
|
||||||
|
|
||||||
|
|
||||||
|
def get_outfile_name(base, count):
|
||||||
|
return base + "_" + str(count).zfill(3) + ".c"
|
||||||
|
|
||||||
|
|
||||||
# The last argument is the base name of the generated C file(s)
|
# The last argument is the base name of the generated C file(s)
|
||||||
output_file_path = sys.argv[-1]
|
output_file_base = sys.argv[-1]
|
||||||
totsize = 0 # amount written
|
totsize = 0 # amount written
|
||||||
fcount = 0
|
fcount = 0
|
||||||
opath = output_file_path + "_" + str(fcount).zfill(3) + ".c"
|
opath = get_outfile_name(output_file_base, fcount)
|
||||||
print('MEMFS: Generating output: ', opath)
|
print('MEMFS: Generating output: ', opath)
|
||||||
g = open(opath, "w")
|
g = open(opath, "w")
|
||||||
|
|
||||||
|
@ -102,14 +106,14 @@ for directory in dirs:
|
||||||
if totsize >= CHUNK:
|
if totsize >= CHUNK:
|
||||||
g.close()
|
g.close()
|
||||||
fcount += 1
|
fcount += 1
|
||||||
opath = output_file_path + "_" + str(fcount).zfill(3) + ".c"
|
opath = get_outfile_name(output_file_base, fcount)
|
||||||
print('MEMFS: Generating output: ', opath)
|
print('MEMFS: Generating output: ', opath)
|
||||||
g = open(opath, "w")
|
g = open(opath, "w")
|
||||||
totsize = 0
|
totsize = 0
|
||||||
|
|
||||||
g.close()
|
g.close()
|
||||||
assert fcount == 3
|
assert fcount == 3
|
||||||
opath = output_file_path + "_final.c"
|
opath = output_file_base + "_final.c"
|
||||||
print('MEMFS: Generating output: ', opath)
|
print('MEMFS: Generating output: ', opath)
|
||||||
g = open(opath, "w")
|
g = open(opath, "w")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue