10
0
mirror of https://gitlab.com/scemama/EZFIO.git synced 2024-12-22 12:23:34 +01:00

Added archive/unarchive scripts

This commit is contained in:
Anthony Scemama 2015-03-03 16:28:24 +01:00
parent 2fe3f824a6
commit cf872f6514
5 changed files with 216 additions and 127 deletions

44
bin/archive_ezfio.py Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env python
import sys
import os
sys.path = [ os.path.dirname(__file__)+"/../Python" ]+sys.path
import cPickle as pickle
from ezfio import ezfio_obj, ezfio
# Hide errors
def f(where,txt):
raise IOError
ezfio.error = f
def main():
if len(sys.argv) == 1:
print "syntax: %s <EZFIO_Filename>"%(sys.argv[0])
sys.exit(1)
ezfio_filename = sys.argv[1]
ezfio.set_filename(ezfio_filename)
get_functions = filter(
lambda x: x.startswith("has_"),
ezfio_obj.__dict__.keys() )
d = {}
for f in get_functions:
f_name = f[4:]
try:
exec """d['%s'] = ezfio.%s"""%(f_name,f_name)
except:
print "%-40s [%5s]"%(f_name, "Empty")
else:
print "%-40s [%5s]"%(f_name, " OK ")
dump = pickle.dumps(d)
file = open(ezfio_filename+".ezar","w")
file.write(dump)
file.close()
if __name__ == "__main__":
main()

51
bin/unarchive_ezfio.py Executable file
View File

@ -0,0 +1,51 @@
#!/usr/bin/env python
import sys
import os
sys.path = [ os.path.dirname(__file__)+"/../Python" ]+sys.path
import cPickle as pickle
from ezfio import ezfio_obj, ezfio
# Hide errors
#def f(where,txt):
# raise IOError
#ezfio.error = f
def main():
if len(sys.argv) == 1:
print "syntax: %s <EZFIO_Archive.ezar>"%(sys.argv[0])
sys.exit(1)
ezfio_filename = sys.argv[1].split(".ezar")[0]
file = open(ezfio_filename+".ezar","r")
dump = file.read()
file.close()
ezfio.set_filename(ezfio_filename)
d = pickle.loads(dump)
set_functions = d.keys()
nerrors_old = len(d)+1
nerrors = nerrors_old+1
while nerrors != nerrors_old:
nerrors_old = nerrors
nerrors = 0
failed = []
for f_name in set_functions:
try:
exec """ezfio.%s = d['%s']"""%(f_name,f_name)
except:
nerrors += 1
failed.append(f_name)
if nerrors != 0:
print "Unarchive failed:"
for i in failed:
print i
sys.exit(1)
if __name__ == "__main__":
main()

View File

@ -42,11 +42,6 @@ logical function ezfio_exists(path)
character*(32) :: V
read(libezfio_iunit,*) V
close(libezfio_iunit)
! integer :: char_to_version
! if (char_to_version(V) > char_to_version(libezfio_version)) then
! call ezfio_error(irp_here, "This file was generated with version "//trim(V)//&
! " but the current installed version is "//trim(libezfio_version)//".")
! endif
endif
end function
@ -63,7 +58,6 @@ subroutine ezfio_mkdir(path)
write(libezfio_iunit,'(A)') libezfio_version
close(libezfio_iunit)
endif
end subroutine
@ -185,6 +179,7 @@ subroutine ezfio_read_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
call ezfio_error(irp_here,'Attribute '//trim(l_filename)//' is not set')
endif
end
subroutine ezfio_write_array_%(type_short)s(dir,fil,rank,dims,dim_max,dat)
implicit none
character*(*), intent(in) :: dir, fil
@ -229,8 +224,8 @@ integer function n_count_%(type_short)s(array,isize,val)
n_count_%(type_short)s = n_count_%(type_short)s +1
endif
enddo
end function
! Build Python functions
"""
for t in format.keys():
@ -368,7 +363,6 @@ subroutine ezfio_open_write_buffer(dir,fil,rank)
endif
write(libezfio_iunit,'(I2)') rank
end
subroutine ezfio_open_read_buffer(dir,fil,rank)

View File

@ -45,8 +45,8 @@ groups = {}
group = None
my_list = []
for line, filename in lines:
line = line.lower()
try:
if len(line.strip()) == 0:
groups[group] = my_list
elif line[0] != ' ': # New group

View File

@ -1 +1 @@
VERSION=1.1.11
VERSION=1.2.1