refactor: Resolve deprecation warnings
This commit is contained in:
parent
ed2a3aa589
commit
be9b18191b
4 changed files with 4 additions and 5 deletions
|
|
@ -282,7 +282,7 @@ class DataExporter:
|
|||
try:
|
||||
sflags = self.docs_to_export.get("flags", "I,U").upper()
|
||||
flags = 0
|
||||
for a in re.split('\W+',sflags):
|
||||
for a in re.split(r'\W+', sflags):
|
||||
flags = flags | reflags.get(a,0)
|
||||
|
||||
c = re.compile(names, flags)
|
||||
|
|
|
|||
|
|
@ -33,8 +33,7 @@ def execute():
|
|||
def scrub_relative_urls(html):
|
||||
"""prepend a slash before a relative url"""
|
||||
try:
|
||||
return re.sub("""src[\s]*=[\s]*['"]files/([^'"]*)['"]""", 'src="/files/\g<1>"', html)
|
||||
# return re.sub("""(src|href)[^\w'"]*['"](?!http|ftp|mailto|/|#|%|{|cid:|\.com/www\.)([^'" >]+)['"]""", '\g<1>="/\g<2>"', html)
|
||||
return re.sub(r'src[\s]*=[\s]*[\'"]files/([^\'"]*)[\'"]', r'src="/files/\g<1>"', html)
|
||||
except:
|
||||
print("Error", html)
|
||||
raise
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ def format_value(value, df=None, doc=None, currency=None, translated=False):
|
|||
return "{}%".format(flt(value, 2))
|
||||
|
||||
elif df.get("fieldtype") in ("Text", "Small Text"):
|
||||
if not re.search("(\<br|\<div|\<p)", value):
|
||||
if not re.search(r"(<br|<div|<p)", value):
|
||||
return frappe.safe_decode(value).replace("\n", "<br>")
|
||||
|
||||
elif df.get("fieldtype") == "Markdown Editor":
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ class TestWebPage(unittest.TestCase):
|
|||
published = 1,
|
||||
content_type = 'Rich Text',
|
||||
main_section = 'rich text',
|
||||
main_section_md = '# h1\n\markdown content',
|
||||
main_section_md = '# h1\nmarkdown content',
|
||||
main_section_html = '<div>html content</div>'
|
||||
)).insert()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue