Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Change rules to detect if file is a standard #8

Merged
merged 1 commit into from
May 22, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions new_aglae_data_converter/globals/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def convert_globals_to_hdf5(
num_processed_files = 0
for global_file in data_files:
# Determine whether the current file contains standards or globals data
if "_std_" in global_file.name:
if is_file_std(global_file.name):
if not standards_file:
continue
file = standards_file
Expand All @@ -63,12 +63,12 @@ def convert_globals_to_hdf5(
continue
file = globals_file

file = standards_file if "_std_" in global_file.name else globals_file
file = standards_file if is_file_std(global_file.name) else globals_file
# Insert the data from the global file into the appropriate HDF5 file
insert_global_file_in_hdf5(file, global_file)
num_processed_files += 1

logger.debug("%s files processed.", num_processed_files)
logger.info("%s files processed.", num_processed_files)
return num_processed_files


Expand Down Expand Up @@ -127,3 +127,7 @@ def get_global_files(folder: pathlib.Path):
for file in files:
if file.suffix[1:] in GLOBALS_FILE_EXTENSIONS:
yield file


def is_file_std(filename: str) -> bool:
return "_std_" in filename.lower()