refactor: Fix regex to avoid deprecation warnings
This commit is contained in:
parent
e1fec81ae3
commit
3c4306c87a
4 changed files with 7 additions and 7 deletions
|
|
@ -915,7 +915,7 @@ def validate_fields(meta):
|
|||
for field in depends_on_fields:
|
||||
depends_on = docfield.get(field, None)
|
||||
if depends_on and ("=" in depends_on) and \
|
||||
re.match("""[\w\.:_]+\s*={1}\s*[\w\.@'"]+""", depends_on):
|
||||
re.match(r'[\w\.:_]+\s*={1}\s*[\w\.@\'"]+', depends_on):
|
||||
frappe.throw(_("Invalid {0} condition").format(frappe.unscrub(field)), frappe.ValidationError)
|
||||
|
||||
def check_table_multiselect_option(docfield):
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class TestDocType(unittest.TestCase):
|
|||
fields=["parent", "depends_on", "collapsible_depends_on", "mandatory_depends_on",\
|
||||
"read_only_depends_on", "fieldname", "fieldtype"])
|
||||
|
||||
pattern = """[\w\.:_]+\s*={1}\s*[\w\.@'"]+"""
|
||||
pattern = r'[\w\.:_]+\s*={1}\s*[\w\.@\'"]+'
|
||||
for field in docfields:
|
||||
for depends_on in ["depends_on", "collapsible_depends_on", "mandatory_depends_on", "read_only_depends_on"]:
|
||||
condition = field.get(depends_on)
|
||||
|
|
@ -517,4 +517,4 @@ def new_doctype(name, unique=0, depends_on='', fields=None):
|
|||
for f in fields:
|
||||
doc.append('fields', f)
|
||||
|
||||
return doc
|
||||
return doc
|
||||
|
|
|
|||
|
|
@ -12,13 +12,13 @@ class TestPrintFormat(unittest.TestCase):
|
|||
def test_print_user(self, style=None):
|
||||
print_html = frappe.get_print("User", "Administrator", style=style)
|
||||
self.assertTrue("<label>First Name: </label>" in print_html)
|
||||
self.assertTrue(re.findall('<div class="col-xs-[^"]*">[\s]*administrator[\s]*</div>', print_html))
|
||||
self.assertTrue(re.findall(r'<div class="col-xs-[^"]*">[\s]*administrator[\s]*</div>', print_html))
|
||||
return print_html
|
||||
|
||||
def test_print_user_standard(self):
|
||||
print_html = self.test_print_user("Standard")
|
||||
self.assertTrue(re.findall('\.print-format {[\s]*font-size: 9pt;', print_html))
|
||||
self.assertFalse(re.findall('th {[\s]*background-color: #eee;[\s]*}', print_html))
|
||||
self.assertTrue(re.findall(r'\.print-format {[\s]*font-size: 9pt;', print_html))
|
||||
self.assertFalse(re.findall(r'th {[\s]*background-color: #eee;[\s]*}', print_html))
|
||||
self.assertFalse("font-family: serif;" in print_html)
|
||||
|
||||
def test_print_user_modern(self):
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ def get_formatted_value(value, field):
|
|||
|
||||
if getattr(field, 'fieldtype', None) in ["Text", "Text Editor"]:
|
||||
value = unescape_html(frappe.safe_decode(value))
|
||||
value = (re.subn(r'<[\s]*(script|style).*?</\1>(?s)', '', text_type(value))[0])
|
||||
value = (re.subn(r'(?s)<[\s]*(script|style).*?</\1>', '', text_type(value))[0])
|
||||
value = ' '.join(value.split())
|
||||
return field.label + " : " + strip_html_tags(text_type(value))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue