Skip to content
Open
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
17 changes: 13 additions & 4 deletions src/prx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,19 @@ def timeit_wrapper(*args, **kwargs):

@timeit
def try_repair_with_gfzrnx(file):
with open(file) as f:
if "gfzrnx" in f.read():
logging.warning(f"File {file} already contains 'gfzrnx', skipping repair.")
return file
def _check_gfzrnx_processing(file):

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure this needs to be a nested function since it's called only once? If it needs to be a function, I'd make a it a module-level function so that it can be unit tested. If not, I'd just place it's code before the if _check_gfzrnx_processing(file):

with open(file) as f:
for line in f:
if "END OF HEADER" in line:
break
if ("gfzrnx" in line) and ("FILE PROCESSING" in line):
return True
return False

if _check_gfzrnx_processing(file):
logging.warning(f"File {file} already contains 'gfzrnx', skipping repair.")
return file

tool_path = shutil.which("gfzrnx")
if tool_path is None:
logger.info(
Expand Down
Loading