浏览代码

fix: Drop compatability code

* Use raw text for regex patterns to avoid Deprecation warnings
version-14
Gavin D'souza 4 年前
父节点
当前提交
b5a121a1cb
共有 2 个文件被更改,包括 12 次插入17 次删除
  1. +11
    -16
      frappe/build.py
  2. +1
    -1
      frappe/core/doctype/data_import/importer.py

+ 11
- 16
frappe/build.py 查看文件

@@ -1,14 +1,11 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors # Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# MIT License. See license.txt # MIT License. See license.txt


from __future__ import print_function, unicode_literals

import os import os
import re import re
import json import json
import shutil import shutil
import warnings
import tempfile
from tempfile import mkdtemp
from distutils.spawn import find_executable from distutils.spawn import find_executable


import frappe import frappe
@@ -16,8 +13,7 @@ from frappe.utils.minify import JavascriptMinify


import click import click
import psutil import psutil
from six import iteritems, text_type
from six.moves.urllib.parse import urlparse
from urllib.parse import urlparse




timestamps = {} timestamps = {}
@@ -75,8 +71,8 @@ def get_assets_link(frappe_head):
from requests import head from requests import head


tag = getoutput( tag = getoutput(
"cd ../apps/frappe && git show-ref --tags -d | grep %s | sed -e 's,.*"
" refs/tags/,,' -e 's/\^{}//'"
r"cd ../apps/frappe && git show-ref --tags -d | grep %s | sed -e 's,.*"
r" refs/tags/,,' -e 's/\^{}//'"
% frappe_head % frappe_head
) )


@@ -99,7 +95,6 @@ def download_frappe_assets(verbose=True):
""" """
from simple_chalk import green from simple_chalk import green
from subprocess import getoutput from subprocess import getoutput
from tempfile import mkdtemp


assets_setup = False assets_setup = False
frappe_head = getoutput("cd ../apps/frappe && git rev-parse HEAD") frappe_head = getoutput("cd ../apps/frappe && git rev-parse HEAD")
@@ -166,7 +161,7 @@ def symlink(target, link_name, overwrite=False):


# Create link to target with temporary filename # Create link to target with temporary filename
while True: while True:
temp_link_name = tempfile.mktemp(dir=link_dir)
temp_link_name = mktemp(dir=link_dir)


# os.* functions mimic as closely as possible system functions # os.* functions mimic as closely as possible system functions
# The POSIX symlink() returns EEXIST if link_name already exists # The POSIX symlink() returns EEXIST if link_name already exists
@@ -348,7 +343,7 @@ def get_build_maps():
if os.path.exists(path): if os.path.exists(path):
with open(path) as f: with open(path) as f:
try: try:
for target, sources in iteritems(json.loads(f.read())):
for target, sources in (json.loads(f.read() or "{}")).items():
# update app path # update app path
source_paths = [] source_paths = []
for source in sources: for source in sources:
@@ -381,7 +376,7 @@ def pack(target, sources, no_compress, verbose):
timestamps[f] = os.path.getmtime(f) timestamps[f] = os.path.getmtime(f)
try: try:
with open(f, "r") as sourcefile: with open(f, "r") as sourcefile:
data = text_type(sourcefile.read(), "utf-8", errors="ignore")
data = str(sourcefile.read(), "utf-8", errors="ignore")


extn = f.rsplit(".", 1)[1] extn = f.rsplit(".", 1)[1]


@@ -396,7 +391,7 @@ def pack(target, sources, no_compress, verbose):
jsm.minify(tmpin, tmpout) jsm.minify(tmpin, tmpout)
minified = tmpout.getvalue() minified = tmpout.getvalue()
if minified: if minified:
outtxt += text_type(minified or "", "utf-8").strip("\n") + ";"
outtxt += str(minified or "", "utf-8").strip("\n") + ";"


if verbose: if verbose:
print("{0}: {1}k".format(f, int(len(minified) / 1024))) print("{0}: {1}k".format(f, int(len(minified) / 1024)))
@@ -426,16 +421,16 @@ def html_to_js_template(path, content):
def scrub_html_template(content): def scrub_html_template(content):
"""Returns HTML content with removed whitespace and comments""" """Returns HTML content with removed whitespace and comments"""
# remove whitespace to a single space # remove whitespace to a single space
content = re.sub("\s+", " ", content)
content = re.sub(r"\s+", " ", content)


# strip comments # strip comments
content = re.sub("(<!--.*?-->)", "", content)
content = re.sub(r"(<!--.*?-->)", "", content)


return content.replace("'", "\'") return content.replace("'", "\'")




def files_dirty(): def files_dirty():
for target, sources in iteritems(get_build_maps()):
for target, sources in get_build_maps().items():
for f in sources: for f in sources:
if ":" in f: if ":" in f:
f, suffix = f.split(":") f, suffix = f.split(":")


+ 1
- 1
frappe/core/doctype/data_import/importer.py 查看文件

@@ -641,7 +641,7 @@ class Row:
return return
elif df.fieldtype == "Duration": elif df.fieldtype == "Duration":
import re import re
is_valid_duration = re.match("^(?:(\d+d)?((^|\s)\d+h)?((^|\s)\d+m)?((^|\s)\d+s)?)$", value)
is_valid_duration = re.match(r"^(?:(\d+d)?((^|\s)\d+h)?((^|\s)\d+m)?((^|\s)\d+s)?)$", value)
if not is_valid_duration: if not is_valid_duration:
self.warnings.append( self.warnings.append(
{ {


正在加载...
取消
保存