Refs #32290 -- Optimized construct_relative_path() by delay computing has_quotes.
This commit is contained in:
parent
547656c850
commit
7d02fa9433
|
@ -235,10 +235,6 @@ def construct_relative_path(current_template_name, relative_name):
|
||||||
Convert a relative path (starting with './' or '../') to the full template
|
Convert a relative path (starting with './' or '../') to the full template
|
||||||
name based on the current_template_name.
|
name based on the current_template_name.
|
||||||
"""
|
"""
|
||||||
has_quotes = (
|
|
||||||
(relative_name.startswith('"') and relative_name.endswith('"')) or
|
|
||||||
(relative_name.startswith("'") and relative_name.endswith("'"))
|
|
||||||
)
|
|
||||||
new_name = relative_name.strip('\'"')
|
new_name = relative_name.strip('\'"')
|
||||||
if not new_name.startswith(('./', '../')):
|
if not new_name.startswith(('./', '../')):
|
||||||
# relative_name is a variable or a literal that doesn't contain a
|
# relative_name is a variable or a literal that doesn't contain a
|
||||||
|
@ -262,6 +258,10 @@ def construct_relative_path(current_template_name, relative_name):
|
||||||
"same template in which the tag appears."
|
"same template in which the tag appears."
|
||||||
% (relative_name, current_template_name)
|
% (relative_name, current_template_name)
|
||||||
)
|
)
|
||||||
|
has_quotes = (
|
||||||
|
relative_name.startswith(('"', "'")) and
|
||||||
|
relative_name[0] == relative_name[-1]
|
||||||
|
)
|
||||||
return f'"{new_name}"' if has_quotes else new_name
|
return f'"{new_name}"' if has_quotes else new_name
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue