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
32 changes: 32 additions & 0 deletions scripts/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Context:
_artifact_name = None
_files_found = []
_filename_lookup_map = {}
_data_folder = None

@staticmethod
def set_output_params(output_params):
Expand All @@ -33,6 +34,7 @@ def set_output_params(output_params):
output_params: The initialized OutputParameters object.
"""
Context._output_params = output_params
Context._data_folder = getattr(output_params, 'data_folder', None)

@staticmethod
def set_report_folder(report_folder):
Expand Down Expand Up @@ -322,6 +324,36 @@ def get_source_file_path(partial_path):

return None

@staticmethod
def get_data_folder():
"""
Returns the global extraction folder path.
"""
return Context._data_folder

@staticmethod
def get_relative_path(full_path):
"""
Converts a full on-disk path (from files_found) to a relative
extraction path by removing the global data_folder prefix.

Args:
full_path (str): The full path to the file.

Returns:
str: The relative extraction path, or the original path if
the data_folder is not available.
"""
if not full_path or not Context._data_folder:
return full_path

if full_path.startswith(Context._data_folder):
# Strip the base path and any leading separators
return full_path[len(Context._data_folder):].lstrip('/\\')

return full_path


@staticmethod
def clear():
"""
Expand Down
Loading