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

Allow path to be pattern in list_dir_names() #92

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

hagenw
Copy link
Member

@hagenw hagenw commented Jan 27, 2023

Considering #76

This extends audeer.list_dir_names(path) by the possibility to provide a pattern as path.
It raises then the same errors as audeer.list_file_names() does in #93.

The only difference is that due to how we recognize what a pattern is it behaves slightly different.
E.g. assume we have a file called path/abc.
Then we would get

>>> audeer.list_file_names('path/abc', basenames=True)
['abc']
>>> audeer.list_file_names('path/a*', basenames=True)
['abc']

Now assume we have a folder called path/abc.
Then we would get

>>> audeer.list_dir_names('path/abc', basenames=True)
[]
>>> audeer.list_dir_names('path/a*', basenames=True)
['abc']

image

@codecov
Copy link

codecov bot commented Jan 27, 2023

Codecov Report

Merging #92 (b4d8b4d) into main (118498b) will not change coverage.
The diff coverage is 100.0%.

Impacted Files Coverage Δ
audeer/core/io.py 100.0% <100.0%> (ø)

@hagenw hagenw changed the title WIP: Allow path to be pattern in list_dir_names() Allow path to be pattern in list_dir_names() Jan 27, 2023
@hagenw hagenw requested a review from frankenjoe January 27, 2023 16:17
@frankenjoe
Copy link
Collaborator

Wouldn't it make sense we first find a solution for #76? I guess with the changes you propose here we no longer raise an error if a directory does not exist, but return an empty list instead.

@hagenw
Copy link
Member Author

hagenw commented Jan 30, 2023

In my opinion #76 is solved by #93.

I guess it was not closed as I wrote "Closing" instead of "Closes" in the pull request ;)

@frankenjoe
Copy link
Collaborator

frankenjoe commented Jan 30, 2023

As far as I see in #93 we only extended the docstring, but we didn't solve the actual issue, namely that the following returns an empty list:

>>> audeer.list_file_names('./does-not-exist/')
[]

and I think the changes proposed here introduce now the same issue for list_dir_names().

@frankenjoe
Copy link
Collaborator

Since we are struggeling to detect if path is a folder or a pattern in #94, I think it is not a good idea to introduce the same issue here. We should consider to introduce a separate pattern argument instead.

@hagenw hagenw marked this pull request as draft January 17, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants