Skip to content

Commit 928b5ce

Browse files
authored
Merge pull request #171 from liormizr/fix_glob_duble_path_issue
fix_glob_duble_path_issue
2 parents c0d77d2 + 542babb commit 928b5ce

File tree

5 files changed

+36
-2
lines changed

5 files changed

+36
-2
lines changed

Diff for: s3path/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from . import accessor
77

8-
__version__ = '0.5.5'
8+
__version__ = '0.5.6'
99
__all__ = (
1010
'register_configuration_parameter',
1111
'StatResult',

Diff for: s3path/current_version.py

+2
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,8 @@ def _deep_cached_dir_scan(self):
738738
target_path_parts = key_parts[:self._target_level]
739739
target_path = ''
740740
for part in target_path_parts:
741+
if not part:
742+
continue
741743
target_path += f'{self._path._flavour.sep}{part}'
742744
if target_path in cache:
743745
continue

Diff for: s3path/old_versions.py

+2
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ def _deep_cached_dir_scan(self):
762762
target_path_parts = key_parts[:self._target_level]
763763
target_path = ''
764764
for part in target_path_parts:
765+
if not part:
766+
continue
765767
target_path += f'{self._path._flavour.sep}{part}'
766768
if target_path in cache:
767769
continue

Diff for: setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
long_description = fh.read()
66
setup(
77
name='s3path',
8-
version='0.5.5',
8+
version='0.5.6',
99
url='https://github.com/liormizr/s3path',
1010
author='Lior Mizrahi',
1111
author_email='[email protected]',

Diff for: tests/test_path_operations.py

+30
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,40 @@ def test_glob_issue_160(s3_mock):
203203
assert sum(1 for _ in path.rglob('output/')) == 4
204204

205205

206+
def test_glob_issue_160_weird_behavior(s3_mock):
207+
s3 = boto3.resource('s3')
208+
s3.create_bucket(Bucket='my-bucket')
209+
210+
first_dir = S3Path.from_uri(f"s3://my-bucket/first_dir/")
211+
new_file = first_dir / "some_dir" / "empty.txt"
212+
new_file.touch()
213+
print()
214+
print(f'Globing: {first_dir=}, pattern: "*"')
215+
assert list(first_dir.glob("*")) == [S3Path('/my-bucket/first_dir/some_dir/')]
216+
217+
second_dir = S3Path.from_uri(f"s3://my-bucket/first_dir/second_dir/")
218+
new_file = second_dir / "some_dir" / "empty.txt"
219+
new_file.touch()
220+
print()
221+
print(f'Globing: {second_dir=}, pattern: "*"')
222+
assert list(second_dir.glob("*")) == [S3Path('/my-bucket/first_dir/second_dir/some_dir/')]
223+
224+
third_dir = S3Path.from_uri(f"s3://my-bucket/first_dir/second_dir/third_dir/")
225+
new_file = third_dir / "some_dir" / "empty.txt"
226+
new_file.touch()
227+
print()
228+
print(f'Globing: {third_dir=}, pattern: "*"')
229+
assert list(third_dir.glob("*")) == [S3Path('/my-bucket/first_dir/second_dir/third_dir/some_dir/')]
230+
231+
206232
def test_glob_issue_160_old_algo(s3_mock, enable_old_glob):
207233
test_glob_issue_160(s3_mock)
208234

209235

236+
def test_glob_issue_160_weird_behavior_old_algo(s3_mock, enable_old_glob):
237+
test_glob_issue_160_weird_behavior(s3_mock)
238+
239+
210240
def test_rglob(s3_mock):
211241
s3 = boto3.resource('s3')
212242
s3.create_bucket(Bucket='test-bucket')

0 commit comments

Comments
 (0)