Skip to content

Commit

Permalink
use iglob python 3.8 version
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Li committed Jun 24, 2024
1 parent 91e81bb commit ba7288c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,9 @@ def any_files(file_names: list, pattern):

# lstrip to handle empty self.path
base_path = self._base_url.replace('\\', '/') if self.is_local_path() else self.path
relative_path_pattern = f"{base_path.rstrip('/')}/{relative_path_pattern.strip('/')}".lstrip("/")
full_path_pattern = f"{base_path.rstrip('/')}/{relative_path_pattern.strip('/')}".lstrip("/")
# find the non-wildcard part of the path
pattern_sections = relative_path_pattern.split("/")
pattern_sections = full_path_pattern.split("/")
for idx in range(len(pattern_sections)):
if "*" in pattern_sections[idx] or '?' in pattern_sections[idx]:
break
Expand All @@ -222,8 +222,8 @@ def any_files(file_names: list, pattern):
# match the wildcard part of the path
container_client = container_client or self.get_container_client()
if not container_client: # local
return any(glob.iglob(path_pattern, root_dir=non_wildcard_path))
elif isinstance(container_client, FileSystemClient): # gen2
return any(glob.iglob(full_path_pattern))
if isinstance(container_client, FileSystemClient): # gen2
paths = container_client.get_paths(non_wildcard_path, True)
file_names = [path.name[len(non_wildcard_path):] for path in paths if not path.is_directory]
else: # blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ class TestMDCPreprocessorHelper:
)
def test_get_file_list(self, start, end, expected_datetimes):
"""Test get_file_list()."""

mock_store_url = Mock(spec=StoreUrl)
mock_store_url.is_local_path.return_value = False
mock_store_url.any_files.side_effect = lambda pattern: pattern in TestMDCPreprocessorHelper.MATCH_PATTERNS
Expand Down

0 comments on commit ba7288c

Please sign in to comment.