Robustified definition of path_to_input_dir arg or parameter by ensuring is always defined using forward slashes and then is normalized to the os specification. Improved dry run = True of copy directory func.
This commit is contained in:
@ -275,28 +275,29 @@ def create_hdf5_file_from_filesystem_path(path_to_input_directory: str,
|
||||
Path to the created HDF5 file.
|
||||
"""
|
||||
|
||||
output_filename = path_to_input_directory + '.h5'
|
||||
|
||||
|
||||
if '/' in path_to_input_directory:
|
||||
path_to_input_directory= path_to_input_directory.replace('/',os.sep)
|
||||
else:
|
||||
|
||||
if not '/' in path_to_input_directory:
|
||||
raise ValueError('path_to_input_directory needs to be specified using forward slashes "/".' )
|
||||
|
||||
#path_to_output_directory = os.path.join(path_to_input_directory,'..')
|
||||
path_to_input_directory = os.path.normpath(path_to_input_directory).strip(os.sep)
|
||||
|
||||
|
||||
for i, keyword in enumerate(select_dir_keywords):
|
||||
select_dir_keywords[i] = keyword.replace('/',os.sep)
|
||||
|
||||
# Copy input_directory into the output_dir_path, and work with it from now on
|
||||
output_dir_path = os.path.splitext(output_filename)[0].replace('/',os.sep)
|
||||
|
||||
if not path_to_filenames_dict:
|
||||
# On dry_run=True, returns path to files dictionary of the output directory without making a actual copy of the input directory
|
||||
path_to_output_directory = os.path.join(path_to_input_directory,'..')
|
||||
path_to_filenames_dict = utils.copy_directory_with_contraints(path_to_input_directory,
|
||||
output_dir_path,
|
||||
path_to_output_directory,
|
||||
dry_run=True)
|
||||
# Set input_directory as copied input directory
|
||||
root_dir = output_dir_path
|
||||
root_dir = path_to_input_directory
|
||||
path_to_output_file = path_to_input_directory.rstrip(os.path.sep) + '.h5'
|
||||
|
||||
with h5py.File(output_filename, mode='w', track_order=True) as h5file:
|
||||
with h5py.File(path_to_output_file, mode='w', track_order=True) as h5file:
|
||||
|
||||
number_of_dirs = len(path_to_filenames_dict.keys())
|
||||
dir_number = 1
|
||||
@ -372,7 +373,7 @@ def create_hdf5_file_from_filesystem_path(path_to_input_directory: str,
|
||||
|
||||
#output_yml_filename_path = hdf5_vis.take_yml_snapshot_of_hdf5_file(output_filename)
|
||||
|
||||
return output_filename #, output_yml_filename_path
|
||||
return path_to_output_file #, output_yml_filename_path
|
||||
|
||||
def save_processed_dataframe_to_hdf5(df, annotator, output_filename): # src_hdf5_path, script_date, script_name):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user