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

Registry files cannot handle file names containing spaces #313

Closed
dokempf opened this issue Jul 18, 2022 · 3 comments · Fixed by #315
Closed

Registry files cannot handle file names containing spaces #313

dokempf opened this issue Jul 18, 2022 · 3 comments · Fixed by #315
Labels
bug Report a problem that needs to be fixed

Comments

@dokempf
Copy link
Contributor

dokempf commented Jul 18, 2022

Description of the problem:

The way that registry.txt files are parsed here does not allow filenames to contain spaces. This could be fixed by implementing advanced parsing that allows escaping using enclosing quotes or backslashes.

Full code that generated the error

With registry.txt in path:

import pooch
P = pooch.create(
    path=pooch.os_cache("test"),
    base_url="ignored"
)
P.load_registry("registry.txt")

Full error message

OSError: Invalid entry in Pooch registry file './registry.txt': expected 2 or 3 elements in line 1 but got 7. Offending entry: '"How To - Minimal Workflow.pdf" sha256:7d4da5fe4d0438437834fe846608b93959dcb80ded941eb85663b2d905c54000 https://heidata.uni-heidelberg.de/api/access/datafile/:persistentId?persistentId=doi:10.11588/data/TJNQZG/DWSXML'
@dokempf dokempf added the bug Report a problem that needs to be fixed label Jul 18, 2022
@leouieda
Copy link
Member

leouieda commented Jul 18, 2022

@dokempf thanks for reporting this as well! Indeed our parsing is very simplistic and doesn't cover this. In hindsight we should have done with a standard format like JSON for the registry file which would have covered all of this. With the current format, you're right that the only way is to improve our parsing to handle quotes and escaping.

Would you or anyone else like to implement this?

@dokempf
Copy link
Contributor Author

dokempf commented Jul 18, 2022

I will do this or ask a student assistant to do so. Will probably use shlex.

@leouieda
Copy link
Member

Awesome! And I didn't know about shlex 🤩

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Report a problem that needs to be fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants