Avoid DeprecationWarning which will turn into SyntaxError in later Python versionsversion-14
@@ -282,7 +282,7 @@ class DataExporter: | |||||
try: | try: | ||||
sflags = self.docs_to_export.get("flags", "I,U").upper() | sflags = self.docs_to_export.get("flags", "I,U").upper() | ||||
flags = 0 | flags = 0 | ||||
for a in re.split('\W+',sflags): | |||||
for a in re.split(r'\W+',sflags): | |||||
flags = flags | reflags.get(a,0) | flags = flags | reflags.get(a,0) | ||||
c = re.compile(names, flags) | c = re.compile(names, flags) | ||||
@@ -92,7 +92,7 @@ class TestDocType(unittest.TestCase): | |||||
fields=["parent", "depends_on", "collapsible_depends_on", "mandatory_depends_on",\ | fields=["parent", "depends_on", "collapsible_depends_on", "mandatory_depends_on",\ | ||||
"read_only_depends_on", "fieldname", "fieldtype"]) | "read_only_depends_on", "fieldname", "fieldtype"]) | ||||
pattern = """[\w\.:_]+\s*={1}\s*[\w\.@'"]+""" | |||||
pattern = r"""[\w\.:_]+\s*={1}\s*[\w\.@'"]+""" | |||||
for field in docfields: | for field in docfields: | ||||
for depends_on in ["depends_on", "collapsible_depends_on", "mandatory_depends_on", "read_only_depends_on"]: | for depends_on in ["depends_on", "collapsible_depends_on", "mandatory_depends_on", "read_only_depends_on"]: | ||||
condition = field.get(depends_on) | condition = field.get(depends_on) | ||||
@@ -284,7 +284,7 @@ class EmailServer: | |||||
flags = [] | flags = [] | ||||
for flag in imaplib.ParseFlags(flag_string) or []: | for flag in imaplib.ParseFlags(flag_string) or []: | ||||
pattern = re.compile("\w+") | |||||
pattern = re.compile(r"\w+") | |||||
match = re.search(pattern, frappe.as_unicode(flag)) | match = re.search(pattern, frappe.as_unicode(flag)) | ||||
flags.append(match.group(0)) | flags.append(match.group(0)) | ||||
@@ -555,7 +555,7 @@ class Email: | |||||
def get_thread_id(self): | def get_thread_id(self): | ||||
"""Extract thread ID from `[]`""" | """Extract thread ID from `[]`""" | ||||
l = re.findall('(?<=\[)[\w/-]+', self.subject) | |||||
l = re.findall(r'(?<=\[)[\w/-]+', self.subject) | |||||
return l and l[0] or None | return l and l[0] or None | ||||
@@ -42,7 +42,7 @@ def make_boilerplate(dest, app_name): | |||||
if hook_key=="app_name" and hook_val.lower().replace(" ", "_") != hook_val: | if hook_key=="app_name" and hook_val.lower().replace(" ", "_") != hook_val: | ||||
print("App Name must be all lowercase and without spaces") | print("App Name must be all lowercase and without spaces") | ||||
hook_val = "" | hook_val = "" | ||||
elif hook_key=="app_title" and not re.match("^(?![\W])[^\d_\s][\w -]+$", hook_val, re.UNICODE): | |||||
elif hook_key=="app_title" and not re.match(r"^(?![\W])[^\d_\s][\w -]+$", hook_val, re.UNICODE): | |||||
print("App Title should start with a letter and it can only consist of letters, numbers, spaces and underscores") | print("App Title should start with a letter and it can only consist of letters, numbers, spaces and underscores") | ||||
hook_val = "" | hook_val = "" | ||||
@@ -98,7 +98,7 @@ class RedisWrapper(redis.Redis): | |||||
return self.keys(key) | return self.keys(key) | ||||
except redis.exceptions.ConnectionError: | except redis.exceptions.ConnectionError: | ||||
regex = re.compile(cstr(key).replace("|", "\|").replace("*", "[\w]*")) | |||||
regex = re.compile(cstr(key).replace("|", r"\|").replace("*", r"[\w]*")) | |||||
return [k for k in list(frappe.local.cache) if regex.match(cstr(k))] | return [k for k in list(frappe.local.cache) if regex.match(cstr(k))] | ||||
def delete_keys(self, key): | def delete_keys(self, key): | ||||