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

Include path when both path and filename specified #9

Merged
merged 3 commits into from
Mar 26, 2019

Conversation

dstansby
Copy link
Contributor

Currently if the filename and path are specified, path is ignored and the file is just downloaded to the current working directory. This should fix it. I've used pathlib because that's what I'm used to, not sure if it wants to be os.path.join instead.

if not filename:
filepath = partial(default_name, path)
elif callable(filename):
filepath = filename
else:
path = pathlib.Path(path)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can path be None here? (I think it can?)

@Cadair
Copy link
Owner

Cadair commented Mar 25, 2019

This has made me think a little more about the filename and path arguments here. I am fine with this change as it is, it still let's everything work and supports both arguments.

The only thing I wonder if it might be worth documenting is that this allows you to specify a full filepath to filename (joining with ./ does nothing if you specific an absolute path). What do you think about that? I know that filename != filepath and that using it like that is a little weird.

@dstansby
Copy link
Contributor Author

The only precedence I can think of is urllib.request.urlretrieve, that only has a filename argument. https://docs.python.org/3.6/library/urllib.request.html#urllib.request.urlretrieve , but I think your suggestions works well too.

1 similar comment
@dstansby
Copy link
Contributor Author

The only precedence I can think of is urllib.request.urlretrieve, that only has a filename argument. https://docs.python.org/3.6/library/urllib.request.html#urllib.request.urlretrieve , but I think your suggestions works well too.

@Cadair Cadair merged commit 844f9c2 into Cadair:master Mar 26, 2019
@Cadair
Copy link
Owner

Cadair commented Mar 26, 2019

Thanks @dstansby

@dstansby dstansby deleted the include-path branch March 26, 2019 13:58
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