-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX Preserve title case when saving through GUI (issue #7824) #7865
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
FIX Preserve title case when saving through GUI (issue #7824) #7865
Conversation
You can reject invalid filenames by passing them to the OS. On Linux:
On Windows:
(too lazy to remember the os.path equivalents but you get the idea). Invalid inputs could either trigger an exception (I guess there's some value in erroring early... perhaps?) or be ignored (i.e. the default filename remains). Or we could just let the error happen later and ignore all this... which may be just fine. (I would suggest NOT trying to sanitize the filename, that's a can of worms I don't want to open... see e.g. https://bugs.python.org/issue27827) Edit: Upon further thought, given that the only point of the default filename is to initialize a GUI dialog, we should just let the dialog do its own normalization of it, and not worry at all about invalid names. In fact I would suggest even keeping the spaces in. It's really not that bad. |
Current coverage is 62.12% (diff: 100%)@@ master #7865 diff @@
==========================================
Files 174 174
Lines 56072 56072
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 34833 34833
Misses 21239 21239
Partials 0 0
|
I think we should err on the side of letting users shoot them selves in the foot here. This will change the default filename from 'figure_1.png' to 'Figure_1.png'. Not sure how big of a deal this is. |
Or 'Figure 1.png'? |
@anntzer, the code is still replacing spaces with underscores, as it should. I would strongly oppose supplying a default filename with spaces in it. Regarding the switch to starting the default with upper case, I would say "no big deal", so I merged it. |
I agree with @efiring. |
If we warned an changing the file name we would warn by default as the default figure name in |
Backported to |
FIX Preserve title case when saving through GUI (issue #7824)
A quick fix to preserve the title case when saving a figure through the GUI (before issue #7824 slips through the cracks).
Currently, it addresses the initial problem stated in #7824 but not the one raised in the discussion by @jkseppan about adding some way of dealing with forbidden characters. My viewpoint is that this could be done in another PR if we define a list of the forbidden characters in file names on the different OSes and which valid character to replace them with.