Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix_glob_duble_path_issue #171

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion s3path/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from . import accessor

__version__ = '0.5.5'
__version__ = '0.5.6'
__all__ = (
'register_configuration_parameter',
'StatResult',
Expand Down
2 changes: 2 additions & 0 deletions s3path/current_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ def _deep_cached_dir_scan(self):
target_path_parts = key_parts[:self._target_level]
target_path = ''
for part in target_path_parts:
if not part:
continue
target_path += f'{self._path._flavour.sep}{part}'
if target_path in cache:
continue
Expand Down
2 changes: 2 additions & 0 deletions s3path/old_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,8 @@ def _deep_cached_dir_scan(self):
target_path_parts = key_parts[:self._target_level]
target_path = ''
for part in target_path_parts:
if not part:
continue
target_path += f'{self._path._flavour.sep}{part}'
if target_path in cache:
continue
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
long_description = fh.read()
setup(
name='s3path',
version='0.5.5',
version='0.5.6',
url='https://github.com/liormizr/s3path',
author='Lior Mizrahi',
author_email='[email protected]',
Expand Down
30 changes: 30 additions & 0 deletions tests/test_path_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,40 @@ def test_glob_issue_160(s3_mock):
assert sum(1 for _ in path.rglob('output/')) == 4


def test_glob_issue_160_weird_behavior(s3_mock):
s3 = boto3.resource('s3')
s3.create_bucket(Bucket='my-bucket')

first_dir = S3Path.from_uri(f"s3://my-bucket/first_dir/")
new_file = first_dir / "some_dir" / "empty.txt"
new_file.touch()
print()
print(f'Globing: {first_dir=}, pattern: "*"')
assert list(first_dir.glob("*")) == [S3Path('/my-bucket/first_dir/some_dir/')]

second_dir = S3Path.from_uri(f"s3://my-bucket/first_dir/second_dir/")
new_file = second_dir / "some_dir" / "empty.txt"
new_file.touch()
print()
print(f'Globing: {second_dir=}, pattern: "*"')
assert list(second_dir.glob("*")) == [S3Path('/my-bucket/first_dir/second_dir/some_dir/')]

third_dir = S3Path.from_uri(f"s3://my-bucket/first_dir/second_dir/third_dir/")
new_file = third_dir / "some_dir" / "empty.txt"
new_file.touch()
print()
print(f'Globing: {third_dir=}, pattern: "*"')
assert list(third_dir.glob("*")) == [S3Path('/my-bucket/first_dir/second_dir/third_dir/some_dir/')]


def test_glob_issue_160_old_algo(s3_mock, enable_old_glob):
test_glob_issue_160(s3_mock)


def test_glob_issue_160_weird_behavior_old_algo(s3_mock, enable_old_glob):
test_glob_issue_160_weird_behavior(s3_mock)


def test_rglob(s3_mock):
s3 = boto3.resource('s3')
s3.create_bucket(Bucket='test-bucket')
Expand Down
Loading