-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
PR: Change the way %(date)s and %(username)s are dealt with in the template.py #6380
PR: Change the way %(date)s and %(username)s are dealt with in the template.py #6380
Conversation
take the part between tripe-double-quotes seperately and deal with it seperately we can replace %(date)s properly no matter what a man add in template.py
Hello @chengtian5huang! Thanks for updating the PR.
Comment last updated on February 10, 2018 at 03:19 Hours UTC |
Thanks for your contribution. There can be several triple quote sections in a template. How does your code deal with that? |
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.
Aside from the minor notes to consider, any way you can add some simple tests for _replace_triple_quote, and maybe new(), to cover the scenarios you've laid out?
@@ -1860,21 +1860,30 @@ def _clone_file_everywhere(self, finfo): | |||
for editorstack in self.editorstacks[1:]: | |||
editor = editorstack.clone_editor_from(finfo, set_current=False) | |||
self.register_widget_shortcuts(editor) | |||
|
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.
Delete extra blank spaces
spyder/plugins/editor.py
Outdated
@@ -1860,21 +1860,30 @@ def _clone_file_everywhere(self, finfo): | |||
for editorstack in self.editorstacks[1:]: | |||
editor = editorstack.clone_editor_from(finfo, set_current=False) | |||
self.register_widget_shortcuts(editor) | |||
|
|||
def _replace_tripe_quote(self, m, v=None): |
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.
Maybe use slightly more descriptive parameter names than just single characters?
spyder/plugins/editor.py
Outdated
from functools import partial | ||
replace = partial(self._replace_tripe_quote, v=VARS) | ||
pat = '"""(?:(?!""").|[\n\r])*"""' | ||
text = re.sub(pat, |
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.
Perhaps a matter of taste, but any reason this can't all go in one line? It would only be 49 chars long...
@CAM-Gerlach text = text % VARS raise an exception i am able to know there is user-specified(which is invaild to spyder) placeholder. try:
text = text % VARS
except (KeyError,TypeError) as err:
text = text.split('\n') # if Macintosh, use \r
for i,line in enumerate(text):
try:
text[i] = line % VARS
except:
pass
text = '\n'.join(text) |
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.
Sorry, but please revert your last commit, as it seems to have little to nothing to do with what I suggested while introducing two major regressions. It removes all whitespace in the entire file, (rather than just the one line you introduced), and nowhere did I say anything about moving your helper function to new(), its better design to keep it separate. Honestly, I'd just git reset --hard HEAD~
then git push -f
and start again from there.
Sorry, but I think we've had a major misunderstanding here. Please see my review comment for more on that specifically.
Umm, what? Where exactly did I ever suggest you do this? It is better design to keep it separate as a helper function as you had it originally, so I have no idea what you thought it should be changed.
I mean unit tests for your code, not anything to do with the program logic you've already written. As you seemed to have an understanding of various cases and how it should handle them, I figured it wouldn't be too difficult to write a few of them into proper tests. At the very least, testing your helper function should be easy to do. If you don't know what unit tests are, I suggest you at least make yourself familiar with them as they are a huge part of programming nowadays;
Not 100% sure what you're proposing nor why, but it seems clear it has nothing to do with what I requested, which were only minor changes and adding tests that had nothing to do with the core logic. |
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.
Thanks, although it would probably just make more sense to just git reset
to before you made that first bad commit and force push that since the last two commits (that commit and the revert) are both consecutive and rather pointless, cluttering the commit history.
Changes reverted, though as mentioned it would really be better IMO to just reset to before the two pointless commits as they are essentially just clutter.
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 honestly have no idea what's going on right now. Now you've reverted your actual good changes too plus added even more pointless revert commits? I don't mean to sound rude, but quite frankly that's exactly the opposite of what I just asked you to do.
Please, just type the following two commands into your git console:
git reset --hard 3206df3
git push -f
which will mercifully undo this mess.
9e8a87a
to
3206df3
Compare
truly sorry for inconvenience. |
Thanks |
if there are invaild placeholders in template.py, check line by line to replace vaild placeholders and ignore the invailds.
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.
You have some PEP8 issues you still need to fix; please see the PEP8Speaks comment. Also, you need to rebase it to incorporate recent changes.
@chengtian5huang Hey, any updates? |
I'm closing this one. I don't understand very well what it tries to fix or improve, sorry. |
Fixes #6379
Take the part between tripe-double-quotes separately and deal with it separately we can replace %(date)s properly no matter what a man add in
template.py