Browse Source

fix: Use raw strings for strings with \

Avoid DeprecationWarning which will turn into SyntaxError in later
Python versions
version-14
Gavin D'souza 4 years ago
parent
commit
b3af9f0c72
5 changed files with 6 additions and 6 deletions
  1. +1
    -1
      frappe/core/doctype/data_export/exporter.py
  2. +1
    -1
      frappe/core/doctype/doctype/test_doctype.py
  3. +2
    -2
      frappe/email/receive.py
  4. +1
    -1
      frappe/utils/boilerplate.py
  5. +1
    -1
      frappe/utils/redis_wrapper.py

+ 1
- 1
frappe/core/doctype/data_export/exporter.py View File

@@ -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)


+ 1
- 1
frappe/core/doctype/doctype/test_doctype.py View File

@@ -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)


+ 2
- 2
frappe/email/receive.py View File

@@ -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






+ 1
- 1
frappe/utils/boilerplate.py View File

@@ -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 = ""




+ 1
- 1
frappe/utils/redis_wrapper.py View File

@@ -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):


Loading…
Cancel
Save