-
Notifications
You must be signed in to change notification settings - Fork 3
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
Accept directory instead of list of files in "multi_slice" converters #32
Comments
I personally use the built-in pathlib package with: import pathlib
input_path = pathlib.Path("...")
if "*" in input_path.name:
for file in input_path.parent.glob(input_path.name):
# ...
elif input_path.is_dir():
for file in input_path.glob("*"):
# .... |
The one thing I am a bit scared of in this case is if the filename really contains a On unix, I can do It's a very unlikely edge case, but thought it's worth mentioning. What we could do is implement your trick only on windows system (where wildecard extension is lacking). There shouldn't be any need for it on unix, I think. |
Oh I wasn't aware that * was a valid character in Unix paths! |
What about this tweak? import pathlib
input_path = pathlib.Path("...")
if "*" in input_path.name and not input_path.exists():
for file in input_path.parent.glob(input_path.name):
# ...
elif input_path.is_dir():
for file in input_path.glob("*"):
# .... |
Or maybe the other way around: import pathlib
input_path = pathlib.Path("...")
if input_path.is_dir():
for file in input_path.glob("*"):
# ....
elif "*" in input_path.name and not input_path.exists():
for file in input_path.parent.glob(input_path.name):
# ...
else:
# ... |
One consideration I had is to let the input be a static defined array instead of a directory or wildcard which might drive things to a wrong direction. As the users can always use the wildcard in cli and that would be extended automatically(and sorted). Another thing I can think of is that we might not want to hardcode the glob expression in the package. But I am open to the change. |
On principle I agree and that was the original design, but apparently wildcards are not expended on windows, and that made it difficult for MariPen to run the easily code during the hackathon. Hence the idea of parsing wildcards when they are not extended (with the caveat mentioned above) |
I see. I will think about how to deal with that. |
Apparently windows does not automatically expand
*.ext
into list of files, which makes using the multi slice converters very painful. What we could do is, if the there is a single input and it is a directory, then we run the command on all files (with some filter?) in that directory.The text was updated successfully, but these errors were encountered: