audeering / audbackend

Manage file storage on different backends
https://audeering.github.io/audbackend/
Other
3 stars 0 forks source link

Backend.ls(): pattern should match basename #153

Closed frankenjoe closed 10 months ago

frankenjoe commented 10 months ago

Currently we apply pattern to the whole path and not just the basename. This leads to the following behavior:

backend.put_file(file, '/sub/file.txt', '1.0.0')
backend.ls('/', pattern='*.txt')
[('/sub/file.txt', '1.0.0')]

but:

ls = backend.ls('/', pattern='f*.txt')
[]

This might not be the expected behavior and I wonder if we should introduce a match_basename argument, to control what part of the file path should be matched. With such an argument the user could then do:

EDIT: we agreed this is a bug and the expected output should be:

ls = backend.ls('/', pattern='f*.txt')
[('/sub/file.txt', '1.0.0')]
hagenw commented 10 months ago

Reading the description of pattern

image

I would say the current behavior is a bug and it should anyway only match the basename. So, I would not introduce a new argument, but change the current behavior.