This commit is contained in:
Si11ium
2019-03-14 22:44:19 +01:00
parent 36d6579e4f
commit 1089943c37

View File

@@ -232,23 +232,27 @@ def line_plot(line_dict_list, filename='lineplot'):
pass pass
def search_and_apply(file_or_folder, plotting_function): def search_and_apply(absolut_file_or_folder, plotting_function, files_to_look_for=[]):
if os.path.isdir(file_or_folder): if os.path.isdir(absolut_file_or_folder):
for sub_file_or_folder in os.scandir(file_or_folder): for sub_file_or_folder in os.scandir(absolut_file_or_folder):
search_and_apply(sub_file_or_folder.path, plotting_function) search_and_apply(sub_file_or_folder.path, plotting_function, files_to_look_for=files_to_look_for)
elif file_or_folder.endswith('.dill') and not os.path.exists('{}.html'.format(file_or_folder[:-5])): elif absolut_file_or_folder.endswith('.dill'):
print('Apply Plotting function "{func}" on file "{file}"'.format(func=plotting_function.__name__, file_or_folder = os.path.split(absolut_file_or_folder)[-1]
file=file_or_folder) if file_or_folder in files_to_look_for and not os.path.exists('{}.html'.format(file_or_folder[:-5])):
) print('Apply Plotting function "{func}" on file "{file}"'.format(func=plotting_function.__name__,
with open(file_or_folder, 'rb') as in_f: file=absolut_file_or_folder)
exp = dill.load(in_f) )
with open(absolut_file_or_folder, 'rb') as in_f:
plotting_function(exp, filename='{}.html'.format(file_or_folder[:-5])) exp = dill.load(in_f)
else: try:
# This was either another FilyType or Plot.html alerady exists. plotting_function(exp, filename='{}.html'.format(absolut_file_or_folder[:-5]))
pass except ValueError:
pass
except AttributeError:
pass
else:
# This was either another FilyType or Plot.html alerady exists.
pass
if __name__ == '__main__': if __name__ == '__main__':
@@ -256,4 +260,4 @@ if __name__ == '__main__':
in_file = args.in_file[0] in_file = args.in_file[0]
out_file = args.out_file out_file = args.out_file
search_and_apply(in_file, plot_latent_trajectories_3D) search_and_apply(in_file, plot_latent_trajectories_3D, ["experiment.dill"])