Skip to content
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
8 changes: 7 additions & 1 deletion awswrangler/s3/_list.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Amazon S3 List Module (PRIVATE)."""

import datetime
import fnmatch
import logging
from typing import Any, Dict, List, Optional, Sequence, Union

Expand Down Expand Up @@ -64,10 +65,12 @@ def _list_objects(
last_modified_begin: Optional[datetime.datetime] = None,
last_modified_end: Optional[datetime.datetime] = None,
boto3_session: Optional[boto3.Session] = None,
wildcard_character: str = "*",
) -> List[str]:
wildcard_prefix: str = path.split(wildcard_character)[0]
bucket: str
prefix: str
bucket, prefix = _utils.parse_path(path=path)
bucket, prefix = _utils.parse_path(path=wildcard_prefix)
_suffix: Union[List[str], None] = [suffix] if isinstance(suffix, str) else suffix
_ignore_suffix: Union[List[str], None] = [ignore_suffix] if isinstance(ignore_suffix, str) else ignore_suffix
client_s3: boto3.client = _utils.client(service_name="s3", session=boto3_session)
Expand Down Expand Up @@ -102,6 +105,9 @@ def _list_objects(
key = pfx["Prefix"]
paths.append(f"s3://{bucket}/{key}")

if wildcard_character in path:
paths = fnmatch.filter(paths, path)

return paths if _ignore_suffix is None else [p for p in paths if p.endswith(tuple(_ignore_suffix)) is False]


Expand Down