Commit 70a64aee by Robert Raposa

Fix code review comment

parent b5a674d9
...@@ -548,14 +548,12 @@ class ParseString(object): ...@@ -548,14 +548,12 @@ class ParseString(object):
The start index of the first single or double quote, or -1 if The start index of the first single or double quote, or -1 if
no quote was found. no quote was found.
""" """
double_quote_index = template.find('"', start_index, end_index) quote_regex = re.compile(r"""['"]""")
single_quote_index = template.find("'", start_index, end_index) start_match = quote_regex.search(template, start_index, end_index)
if 0 <= single_quote_index or 0 <= double_quote_index: if start_match is None:
if 0 <= single_quote_index and 0 <= double_quote_index: return -1
return min(single_quote_index, double_quote_index) else:
else: return start_match.start()
return max(single_quote_index, double_quote_index)
return -1
def _parse_string(self, template, start_index): def _parse_string(self, template, start_index):
""" """
...@@ -801,7 +799,7 @@ class MakoTemplateLinter(object): ...@@ -801,7 +799,7 @@ class MakoTemplateLinter(object):
close_paren_index = self._find_closing_char_index( close_paren_index = self._find_closing_char_index(
None, "(", ")", expression_inner, start_index=len('HTML('), num_open_chars=0, strings=[] None, "(", ")", expression_inner, start_index=len('HTML('), num_open_chars=0, strings=[]
)['close_char_index'] )['close_char_index']
# check that the close paren is at the end of the expression. # check that the close paren is at the end of the stripped expression.
if close_paren_index != len(expression_inner) - 1: if close_paren_index != len(expression_inner) - 1:
results.violations.append(ExpressionRuleViolation( results.violations.append(ExpressionRuleViolation(
Rules.mako_html_alone, expression Rules.mako_html_alone, expression
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment