fix: Use raw string to avoid invalid sequence errors
Escaped when proven easier
This commit is contained in:
parent
131cfaee8b
commit
f6b215938a
3 changed files with 6 additions and 6 deletions
|
|
@ -589,7 +589,7 @@ def is_translatable(m):
|
|||
def add_line_number(messages, code):
|
||||
ret = []
|
||||
messages = sorted(messages, key=lambda x: x[0])
|
||||
newlines = [m.start() for m in re.compile('\\n').finditer(code)]
|
||||
newlines = [m.start() for m in re.compile(r'\n').finditer(code)]
|
||||
line = 1
|
||||
newline_i = 0
|
||||
for pos, message, context in messages:
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ def split_emails(txt):
|
|||
|
||||
# emails can be separated by comma or newline
|
||||
s = re.sub(r'[\t\n\r]', ' ', cstr(txt))
|
||||
for email in re.split('''[,\\n](?=(?:[^"]|"[^"]*")*$)''', s):
|
||||
for email in re.split(r'[,\n](?=(?:[^"]|"[^"]*")*$)', s):
|
||||
email = strip(cstr(email))
|
||||
if email:
|
||||
email_list.append(email)
|
||||
|
|
|
|||
|
|
@ -454,7 +454,7 @@ def duration_to_seconds(duration):
|
|||
|
||||
def validate_duration_format(duration):
|
||||
import re
|
||||
is_valid_duration = re.match("^(?:(\d+d)?((^|\s)\d+h)?((^|\s)\d+m)?((^|\s)\d+s)?)$", duration)
|
||||
is_valid_duration = re.match(r"^(?:(\d+d)?((^|\s)\d+h)?((^|\s)\d+m)?((^|\s)\d+s)?)$", duration)
|
||||
if not is_valid_duration:
|
||||
frappe.throw(frappe._("Value {0} must be in the valid duration format: d h m s").format(frappe.bold(duration)))
|
||||
|
||||
|
|
@ -1341,10 +1341,10 @@ def expand_relative_urls(html):
|
|||
|
||||
return "".join(to_expand)
|
||||
|
||||
html = re.sub('(href|src){1}([\s]*=[\s]*[\'"]?)((?!http)[^\'" >]+)([\'"]?)', _expand_relative_urls, html)
|
||||
html = re.sub(r'(href|src){1}([\s]*=[\s]*[\'"]?)((?!http)[^\'" >]+)([\'"]?)', _expand_relative_urls, html)
|
||||
|
||||
# background-image: url('/assets/...')
|
||||
html = re.sub('(:[\s]?url)(\([\'"]?)((?!http)[^\'" >]+)([\'"]?\))', _expand_relative_urls, html)
|
||||
html = re.sub(r'(:[\s]?url)(\([\'"]?)((?!http)[^\'" >]+)([\'"]?\))', _expand_relative_urls, html)
|
||||
return html
|
||||
|
||||
def quoted(url):
|
||||
|
|
@ -1355,7 +1355,7 @@ def quote_urls(html):
|
|||
groups = list(match.groups())
|
||||
groups[2] = quoted(groups[2])
|
||||
return "".join(groups)
|
||||
return re.sub('(href|src){1}([\s]*=[\s]*[\'"]?)((?:http)[^\'">]+)([\'"]?)',
|
||||
return re.sub(r'(href|src){1}([\s]*=[\s]*[\'"]?)((?:http)[^\'">]+)([\'"]?)',
|
||||
_quote_url, html)
|
||||
|
||||
def unique(seq):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue