10
0
mirror of https://gitlab.com/scemama/EZFIO.git synced 2024-11-19 12:32:24 +01:00
EZFIO/bin/archive_ezfio.py

53 lines
1.1 KiB
Python
Raw Normal View History

2020-01-27 11:32:17 +01:00
#!/usr/bin/env python3
2015-03-03 16:28:24 +01:00
import sys
import os
sys.path = [ os.path.dirname(__file__)+"/../Python" ]+sys.path
2020-01-27 11:32:17 +01:00
import pickle as pickle
2015-03-03 18:11:32 +01:00
import zlib
2015-03-03 16:28:24 +01:00
from ezfio import ezfio_obj, ezfio
# Hide errors
def f(where,txt):
raise IOError
ezfio.error = f
def main():
2015-03-03 18:11:32 +01:00
do_verbose = False
if "-v" in sys.argv:
do_verbose = True
sys.argv.remove("-v")
2015-03-03 16:28:24 +01:00
if len(sys.argv) == 1:
2020-01-27 11:32:17 +01:00
print(("syntax: %s <EZFIO_Filename>"%(sys.argv[0])))
2015-03-03 16:28:24 +01:00
sys.exit(1)
ezfio_filename = sys.argv[1]
2015-03-03 18:11:32 +01:00
while ezfio_filename[-1] == "/":
ezfio_filename = ezfio_filename[:-1]
2015-03-03 16:28:24 +01:00
ezfio.set_filename(ezfio_filename)
2020-01-27 11:32:17 +01:00
get_functions = [x for x in list(ezfio_obj.__dict__.keys()) if x.startswith("has_")]
2015-03-03 16:28:24 +01:00
d = {}
for f in get_functions:
f_name = f[4:]
try:
2020-01-27 11:32:17 +01:00
exec("""d['%s'] = ezfio.%s"""%(f_name,f_name))
except:
2015-03-03 18:11:32 +01:00
if do_verbose:
2020-01-27 11:32:17 +01:00
print(("%-40s [%5s]"%(f_name, "Empty")))
2015-03-03 16:28:24 +01:00
else:
2015-03-03 18:11:32 +01:00
if do_verbose:
2020-01-27 11:32:17 +01:00
print(("%-40s [%5s]"%(f_name, " OK ")))
2015-03-03 16:28:24 +01:00
2015-03-03 18:11:32 +01:00
dump = zlib.compress(pickle.dumps(d))
2015-03-03 16:28:24 +01:00
file = open(ezfio_filename+".ezar","w")
file.write(dump)
file.close()
if __name__ == "__main__":
main()