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

Try expanding user for _open_file_or_url. #4510

Merged
merged 1 commit into from Jun 9, 2015

Conversation

chebee7i
Copy link
Contributor

@chebee7i chebee7i commented Jun 9, 2015

When opening a file, this attempts to expand the userpath if the initial open doesn't succeed.

This enables calls such as plt.style.use('~/.config/matplotlib/matplotlibrc').

@WeatherGod
Copy link
Member

I am -1 on this. I have a philosophy of all magic being shallow. What is the usecase of having this function perform the expansion as opposed to having the user do it when it calls plt.style.use()?

@chebee7i
Copy link
Contributor Author

chebee7i commented Jun 9, 2015

Yeah I could see it either way. I think it's convenience. In most minds of most users, ~/blah is a valid path and so the function should accept it. Making the user convert is a mild annoyance.

@chebee7i
Copy link
Contributor Author

chebee7i commented Jun 9, 2015

The magic in this case is also fairly benign. The standard case is still attempted first, and the fallback only works on fnames which are never valid literal paths on any OS I've used.

@efiring
Copy link
Member

efiring commented Jun 9, 2015

This seems to me like a good idea. I don't see any disadvantage. We are using our own _get_home() extensively in mpl's startup, and allowing '~/config' in plt.style.use() is in that spirit.

@WeatherGod
Copy link
Member

ok, perhaps I can be convinced, however the error handling will need to be fixed. If neither attempt works, it will only report the failure of the second attempt. We would need proper error messaging.

@chebee7i
Copy link
Contributor Author

chebee7i commented Jun 9, 2015

Aha, yes that needs fixing. style.use handles it correctly b/c it just catches and returns its own message, I think, but when called on its own, this needs adjusting.

@tacaswell
Copy link
Member

Why not always call expand_user?

@tacaswell tacaswell added this to the next point release milestone Jun 9, 2015
@chebee7i
Copy link
Contributor Author

chebee7i commented Jun 9, 2015

That should be safe too...I was being overly conservative. With that change made, I guess the error handling is fine as is?

@tacaswell
Copy link
Member

👍 from me

efiring added a commit that referenced this pull request Jun 9, 2015
Try expanding user for _open_file_or_url.
@efiring efiring merged commit d4c8700 into matplotlib:master Jun 9, 2015
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.

None yet

4 participants