utils/{check-package, checkpackagelib}: consistently use raw strings for re.compile
Raw strings need to be used when calling re.compile() otherwise Python 3.x flake8 complains with: W605 invalid escape sequence '\s' Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Reviewed-by: Titouan Christophe <titouan.christophe@railnova.eu> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
@@ -46,24 +46,24 @@ def parse_args():
|
|||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
CONFIG_IN_FILENAME = re.compile("Config\.\S*$")
|
CONFIG_IN_FILENAME = re.compile(r"Config\.\S*$")
|
||||||
DO_CHECK_INTREE = re.compile("|".join([
|
DO_CHECK_INTREE = re.compile(r"|".join([
|
||||||
"Config.in",
|
r"Config.in",
|
||||||
"arch/",
|
r"arch/",
|
||||||
"boot/",
|
r"boot/",
|
||||||
"fs/",
|
r"fs/",
|
||||||
"linux/",
|
r"linux/",
|
||||||
"package/",
|
r"package/",
|
||||||
"system/",
|
r"system/",
|
||||||
"toolchain/",
|
r"toolchain/",
|
||||||
]))
|
]))
|
||||||
DO_NOT_CHECK_INTREE = re.compile("|".join([
|
DO_NOT_CHECK_INTREE = re.compile(r"|".join([
|
||||||
"boot/barebox/barebox\.mk$",
|
r"boot/barebox/barebox\.mk$",
|
||||||
"fs/common\.mk$",
|
r"fs/common\.mk$",
|
||||||
"package/doc-asciidoc\.mk$",
|
r"package/doc-asciidoc\.mk$",
|
||||||
"package/pkg-\S*\.mk$",
|
r"package/pkg-\S*\.mk$",
|
||||||
"toolchain/helpers\.mk$",
|
r"toolchain/helpers\.mk$",
|
||||||
"toolchain/toolchain-external/pkg-toolchain-external\.mk$",
|
r"toolchain/toolchain-external/pkg-toolchain-external\.mk$",
|
||||||
]))
|
]))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -152,8 +152,8 @@ class CommentsMenusPackagesOrder(_CheckFunction):
|
|||||||
|
|
||||||
|
|
||||||
class HelpText(_CheckFunction):
|
class HelpText(_CheckFunction):
|
||||||
HELP_TEXT_FORMAT = re.compile("^\t .{,62}$")
|
HELP_TEXT_FORMAT = re.compile(r"^\t .{,62}$")
|
||||||
URL_ONLY = re.compile("^(http|https|git)://\S*$")
|
URL_ONLY = re.compile(r"^(http|https|git)://\S*$")
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
self.help_text = False
|
self.help_text = False
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ end_conditional = ["endif"]
|
|||||||
|
|
||||||
|
|
||||||
class Indent(_CheckFunction):
|
class Indent(_CheckFunction):
|
||||||
COMMENT = re.compile("^\s*#")
|
COMMENT = re.compile(r"^\s*#")
|
||||||
CONDITIONAL = re.compile("^\s*({})\s".format("|".join(start_conditional + end_conditional)))
|
CONDITIONAL = re.compile(r"^\s*({})\s".format("|".join(start_conditional + end_conditional)))
|
||||||
ENDS_WITH_BACKSLASH = re.compile(r"^[^#].*\\$")
|
ENDS_WITH_BACKSLASH = re.compile(r"^[^#].*\\$")
|
||||||
END_DEFINE = re.compile("^\s*endef\s")
|
END_DEFINE = re.compile(r"^\s*endef\s")
|
||||||
MAKEFILE_TARGET = re.compile("^[^# \t]+:\s")
|
MAKEFILE_TARGET = re.compile(r"^[^# \t]+:\s")
|
||||||
START_DEFINE = re.compile("^\s*define\s")
|
START_DEFINE = re.compile(r"^\s*define\s")
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
self.define = False
|
self.define = False
|
||||||
@@ -76,17 +76,17 @@ class Indent(_CheckFunction):
|
|||||||
|
|
||||||
|
|
||||||
class OverriddenVariable(_CheckFunction):
|
class OverriddenVariable(_CheckFunction):
|
||||||
CONCATENATING = re.compile("^([A-Z0-9_]+)\s*(\+|:|)=\s*\$\(\\1\)")
|
CONCATENATING = re.compile(r"^([A-Z0-9_]+)\s*(\+|:|)=\s*\$\(\\1\)")
|
||||||
END_CONDITIONAL = re.compile("^\s*({})".format("|".join(end_conditional)))
|
END_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(end_conditional)))
|
||||||
OVERRIDING_ASSIGNMENTS = [':=', "="]
|
OVERRIDING_ASSIGNMENTS = [':=', "="]
|
||||||
START_CONDITIONAL = re.compile("^\s*({})".format("|".join(start_conditional)))
|
START_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(start_conditional)))
|
||||||
VARIABLE = re.compile("^([A-Z0-9_]+)\s*((\+|:|)=)")
|
VARIABLE = re.compile(r"^([A-Z0-9_]+)\s*((\+|:|)=)")
|
||||||
USUALLY_OVERRIDDEN = re.compile("^[A-Z0-9_]+({})".format("|".join([
|
USUALLY_OVERRIDDEN = re.compile(r"^[A-Z0-9_]+({})".format("|".join([
|
||||||
"_ARCH\s*=\s*",
|
r"_ARCH\s*=\s*",
|
||||||
"_CPU\s*=\s*",
|
r"_CPU\s*=\s*",
|
||||||
"_SITE\s*=\s*",
|
r"_SITE\s*=\s*",
|
||||||
"_SOURCE\s*=\s*",
|
r"_SOURCE\s*=\s*",
|
||||||
"_VERSION\s*=\s*"])))
|
r"_VERSION\s*=\s*"])))
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
self.conditional = 0
|
self.conditional = 0
|
||||||
@@ -174,7 +174,7 @@ class RemoveDefaultPackageSourceVariable(_CheckFunction):
|
|||||||
package_upper = package.replace("-", "_").upper()
|
package_upper = package.replace("-", "_").upper()
|
||||||
self.package = package
|
self.package = package
|
||||||
self.FIND_SOURCE = re.compile(
|
self.FIND_SOURCE = re.compile(
|
||||||
"^{}_SOURCE\s*=\s*{}-\$\({}_VERSION\)\.tar\.gz"
|
r"^{}_SOURCE\s*=\s*{}-\$\({}_VERSION\)\.tar\.gz"
|
||||||
.format(package_upper, package, package_upper))
|
.format(package_upper, package, package_upper))
|
||||||
|
|
||||||
def check_line(self, lineno, text):
|
def check_line(self, lineno, text):
|
||||||
@@ -222,7 +222,7 @@ class TrailingBackslash(_CheckFunction):
|
|||||||
|
|
||||||
|
|
||||||
class TypoInPackageVariable(_CheckFunction):
|
class TypoInPackageVariable(_CheckFunction):
|
||||||
ALLOWED = re.compile("|".join([
|
ALLOWED = re.compile(r"|".join([
|
||||||
"ACLOCAL_DIR",
|
"ACLOCAL_DIR",
|
||||||
"ACLOCAL_HOST_DIR",
|
"ACLOCAL_HOST_DIR",
|
||||||
"ACLOCAL_PATH",
|
"ACLOCAL_PATH",
|
||||||
@@ -241,7 +241,7 @@ class TypoInPackageVariable(_CheckFunction):
|
|||||||
"TARGET_FINALIZE_HOOKS",
|
"TARGET_FINALIZE_HOOKS",
|
||||||
"TARGETS_ROOTFS",
|
"TARGETS_ROOTFS",
|
||||||
"XTENSA_CORE_NAME"]))
|
"XTENSA_CORE_NAME"]))
|
||||||
VARIABLE = re.compile("^([A-Z0-9_]+_[A-Z0-9_]+)\s*(\+|)=")
|
VARIABLE = re.compile(r"^([A-Z0-9_]+_[A-Z0-9_]+)\s*(\+|)=")
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
package, _ = os.path.splitext(os.path.basename(self.filename))
|
package, _ = os.path.splitext(os.path.basename(self.filename))
|
||||||
@@ -251,9 +251,9 @@ class TypoInPackageVariable(_CheckFunction):
|
|||||||
# linux extensions do not use LINUX_EXT_ prefix for variables
|
# linux extensions do not use LINUX_EXT_ prefix for variables
|
||||||
package = package.replace("LINUX_EXT_", "")
|
package = package.replace("LINUX_EXT_", "")
|
||||||
self.package = package
|
self.package = package
|
||||||
self.REGEX = re.compile("^(HOST_|ROOTFS_)?({}_[A-Z0-9_]+)".format(package))
|
self.REGEX = re.compile(r"^(HOST_|ROOTFS_)?({}_[A-Z0-9_]+)".format(package))
|
||||||
self.FIND_VIRTUAL = re.compile(
|
self.FIND_VIRTUAL = re.compile(
|
||||||
"^{}_PROVIDES\s*(\+|)=\s*(.*)".format(package))
|
r"^{}_PROVIDES\s*(\+|)=\s*(.*)".format(package))
|
||||||
self.virtual = []
|
self.virtual = []
|
||||||
|
|
||||||
def check_line(self, lineno, text):
|
def check_line(self, lineno, text):
|
||||||
@@ -281,16 +281,16 @@ class TypoInPackageVariable(_CheckFunction):
|
|||||||
|
|
||||||
|
|
||||||
class UselessFlag(_CheckFunction):
|
class UselessFlag(_CheckFunction):
|
||||||
DEFAULT_AUTOTOOLS_FLAG = re.compile("^.*{}".format("|".join([
|
DEFAULT_AUTOTOOLS_FLAG = re.compile(r"^.*{}".format("|".join([
|
||||||
"_AUTORECONF\s*=\s*NO",
|
r"_AUTORECONF\s*=\s*NO",
|
||||||
"_LIBTOOL_PATCH\s*=\s*YES"])))
|
r"_LIBTOOL_PATCH\s*=\s*YES"])))
|
||||||
DEFAULT_GENERIC_FLAG = re.compile("^.*{}".format("|".join([
|
DEFAULT_GENERIC_FLAG = re.compile(r"^.*{}".format("|".join([
|
||||||
"_INSTALL_IMAGES\s*=\s*NO",
|
r"_INSTALL_IMAGES\s*=\s*NO",
|
||||||
"_INSTALL_REDISTRIBUTE\s*=\s*YES",
|
r"_INSTALL_REDISTRIBUTE\s*=\s*YES",
|
||||||
"_INSTALL_STAGING\s*=\s*NO",
|
r"_INSTALL_STAGING\s*=\s*NO",
|
||||||
"_INSTALL_TARGET\s*=\s*YES"])))
|
r"_INSTALL_TARGET\s*=\s*YES"])))
|
||||||
END_CONDITIONAL = re.compile("^\s*({})".format("|".join(end_conditional)))
|
END_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(end_conditional)))
|
||||||
START_CONDITIONAL = re.compile("^\s*({})".format("|".join(start_conditional)))
|
START_CONDITIONAL = re.compile(r"^\s*({})".format("|".join(start_conditional)))
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
self.conditional = 0
|
self.conditional = 0
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ from checkpackagelib.lib import NewlineAtEof # noqa: F401
|
|||||||
|
|
||||||
|
|
||||||
class ApplyOrder(_CheckFunction):
|
class ApplyOrder(_CheckFunction):
|
||||||
APPLY_ORDER = re.compile("\d{1,4}-[^/]*$")
|
APPLY_ORDER = re.compile(r"\d{1,4}-[^/]*$")
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
if not self.APPLY_ORDER.match(os.path.basename(self.filename)):
|
if not self.APPLY_ORDER.match(os.path.basename(self.filename)):
|
||||||
@@ -21,7 +21,7 @@ class ApplyOrder(_CheckFunction):
|
|||||||
|
|
||||||
|
|
||||||
class NumberedSubject(_CheckFunction):
|
class NumberedSubject(_CheckFunction):
|
||||||
NUMBERED_PATCH = re.compile("Subject:\s*\[PATCH\s*\d+/\d+\]")
|
NUMBERED_PATCH = re.compile(r"Subject:\s*\[PATCH\s*\d+/\d+\]")
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
self.git_patch = False
|
self.git_patch = False
|
||||||
@@ -44,7 +44,7 @@ class NumberedSubject(_CheckFunction):
|
|||||||
|
|
||||||
|
|
||||||
class Sob(_CheckFunction):
|
class Sob(_CheckFunction):
|
||||||
SOB_ENTRY = re.compile("^Signed-off-by: .*$")
|
SOB_ENTRY = re.compile(r"^Signed-off-by: .*$")
|
||||||
|
|
||||||
def before(self):
|
def before(self):
|
||||||
self.found = False
|
self.found = False
|
||||||
|
|||||||
Reference in New Issue
Block a user