Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
7fb19409
Commit
7fb19409
authored
Oct 30, 2015
by
Jacek Sowiński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Substitute only if it makes sense
parent
64ac9adb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
24 deletions
+26
-24
topydo/lib/PrettyPrinterFilter.py
topydo/lib/PrettyPrinterFilter.py
+26
-24
No files found.
topydo/lib/PrettyPrinterFilter.py
View file @
7fb19409
...
@@ -193,30 +193,32 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter):
...
@@ -193,30 +193,32 @@ class PrettyPrinterFormatFilter(PrettyPrinterFilter):
r'(?P<after>{{.+?}})?'
r'(?P<after>{{.+?}})?'
r'(?P<whitespace>
\
s)*
'
r'(?P<whitespace>
\
s)*
'
r'(?P<end>.*)').format(placeholder)
r'(?P<end>.*)').format(placeholder)
if repl == '':
match = re.match(pattern, p_todo_str)
p_todo_str = re.sub(pattern, match.group('start') + match.group('end'), p_todo_str)
if match:
else:
if repl == '':
def strip_braces(p_matchobj):
p_todo_str = re.sub(pattern, match.group('start') + match.group('end'), p_todo_str)
try:
else:
before = p_matchobj.group('before').strip('{}')
def strip_braces(p_matchobj):
except AttributeError:
try:
before = ''
before = p_matchobj.group('before').strip('{}')
except AttributeError:
placeholder = p_matchobj.group('placeholder')
before = ''
try:
placeholder = p_matchobj.group('placeholder')
after = p_matchobj.group('after').strip('{}')
except AttributeError:
try:
after = ''
after = p_matchobj.group('after').strip('{}')
except AttributeError:
whitespace = p_matchobj.group('whitespace') or ''
after = ''
start = p_matchobj.group('start') or ''
end = p_matchobj.group('end') or ''
whitespace = p_matchobj.group('whitespace') or ''
start = p_matchobj.group('start') or ''
return start + before + '%' + placeholder + after + whitespace + end
end = p_matchobj.group('end') or ''
p_todo_str = re.sub(pattern, strip_braces, p_todo_str)
return start + before + '%' + placeholder + after + whitespace + end
p_todo_str = re.sub(r'%{}'.format(placeholder), repl, p_todo_str)
p_todo_str = re.sub(pattern, strip_braces, p_todo_str)
p_todo_str = re.sub(r'%{}'.format(placeholder), repl, p_todo_str)
return p_todo_str.rstrip()
return p_todo_str.rstrip()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment