Skip to content

Commit

Permalink
Updating the regex to be tighter. (#36)
Browse files Browse the repository at this point in the history
Ensuring we don't pick up undesired files due to a looser regex.

---------

Co-authored-by: Mark <[email protected]>
  • Loading branch information
THOR300 and Mark authored Apr 12, 2023
1 parent fba27e0 commit e070ce1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/navigator_data_ingest/base/updated_document_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@
_LOGGER = logging.getLogger(__file__)


def get_document_files(
prefix_path: S3Path, document_id: str, suffix_filter: str
) -> List[S3Path]:
"""Get the document files for a given document ID found in an s3 directory."""
return list(prefix_path.glob(f"{document_id}.{suffix_filter}")) + list(
prefix_path.glob(f"{document_id}_translated_*.{suffix_filter}")
)


def handle_document_updates(
executor: Executor,
source: Generator[Tuple[str, List[Update]], None, None],
Expand Down Expand Up @@ -144,7 +153,9 @@ def update_dont_parse(
),
]:
# Might be translated and non-translated json objects
document_files = list(prefix_path.glob(f"{document_id}*.json"))
document_files = get_document_files(
prefix_path, document_id, suffix_filter="json"
)
for document_file in document_files:
errors.append(
update_file_field(
Expand Down Expand Up @@ -218,7 +229,9 @@ def parse(
),
]:
# Might be translated and non-translated json objects
document_files = list(prefix_path.glob(f"{document_id}*.json"))
document_files = get_document_files(
prefix_path, document_id, suffix_filter="json"
)
for document_file in document_files:
errors.append(
update_file_field(
Expand All @@ -239,7 +252,7 @@ def parse(
)

# Might be translated and non-translated json objects
document_files = list(prefix_path.glob(f"{document_id}*.*"))
document_files = get_document_files(prefix_path, document_id, suffix_filter="*")
for document_file in document_files:
errors.append(
rename(
Expand Down

0 comments on commit e070ce1

Please sign in to comment.