Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Use
string.Template
when creating a new file #21706base: master
Are you sure you want to change the base?
Use
string.Template
when creating a new file #21706Changes from all commits
83b20f5
9fc35c0
baa0359
bb14240
67ea36e
a482acb
9f53443
e354f62
289ef8f
5f249a6
cc34075
0b24b4b
92f3c29
cc1af5d
059d98f
e23fdfc
5e325a4
f082e6f
ece32b7
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO, I'm not sure how much value these fields really add by default, at least to the header (as opposed to in a user's own custom template)? IIRC, years ago we simplified this quite a bit because users complained that it was too long. And as to the specific fields:
untitledN.py
at creation time when this is generated? And even if not, given its already displayed in the editor, file manager, etc. as the canonical, up to date source of truth, and is the name of the module when imported or the script when run, and likely to drift out of date if it changes, I don't see how it adds value to duplicate the information here.I could certainly see them making sense in some user-created templates, but I'm not seeing the case for adding them by default. Therefore:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that's to everyone's liking. That's why we have templates, don't we?
Personally I always find it easier to delete tokens than to look up, which tokens are available. That's why I added maybe to many to the default?
There are three reasons why I added
${file}
and${projectname}
: Firstly, sometimes I move around or rename files inside a project or even split a project into two. If you were to do it with out using git, it is so much easier to move them back to their original place. Secondly, files published tend to appear all over the Net and you never know, where they originally come from. This information might help (mind you, it's not foolproof, because this information can be deleted). Thirdly, I once accidentally deleted a bunch of files. Recovering them gave me their contents, but not their name or place in the directory tree.Re the copyright notice: If someone reused your file in one of his/her projects, the copyright notice often gets lost; often not of malice, but because it is cumbersome to track down the original copyright holder and insert it into the file's header. Including the copyright notice per default makes this in my view so much easier.
What do you think? I do not have a strong feeling to remove them, but they might be useful. What do the users say? You probably know that better than I do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be made much simpler and more reliable by using the built-in standard mechanism for retrieving the current username,
getpass.getuser()
, and for the display/full name use pywin32 for Windows (since its already a Spyder dependency).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I missed that spyder is already depending on these Windows module (I am not working on Windows myself) …
But what is the effect of importing the same object from different modules in these two lines:
As for the Linux part: I wanted to avoid to import another module, that's why I took that root.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I'd suggest just falling back to the username if there is no separate display name defined, as it seems much more sensible behavior for realistic use cases, and avoids the need to handle (and translate) a default.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also considered to use
username
as alternative, ifdisplayname
is not available. I decided against it, because I believed that it might come to a surprise, if one usesfullname
and suddenly just thedisplayname
is inserted. Maybe we should haveusername
,fullname
andfull_or_username
(or something similar)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not totally sure what to do about these in the case of no project being active. For starters, we should use proper capitalization, and calling
_()
will translate the string, i.e.We could just fall back to
getcwd_or_home()
, as Spyder does for the default working dir when no project is active. i.e.:There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am used to both ways: ‘n/a’ and ‘N/A’. When working in the UK I got the feeling, that ‘n/a’ was more common. So does www.leo.org only shows ‘n/a’. On the other hand, wikipedia has an entry for ‘N/A’. I don't have any preferences here.
I prefer to show, that the file is not part of a project instead of using the current working directory or even home. Otherwise one might think, that the file is part of a project, which it is not.