summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-14 15:50:51 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-01-16 15:35:07 +0000
commite5455662a9762fc2cb8859134d855413d84fd265 (patch)
treead7c3c6b258415ab9b92ed4b04a1ce0c2f6c9eb7 /bitbake/lib
parentca4a8eea6284aad41ec67b375c2a7c7855b5fe11 (diff)
downloadpoky-e5455662a9762fc2cb8859134d855413d84fd265.tar.gz
bitbake: bitbake: Fix Deprecated warnings from regexs
Fix handling of escape characters in regexs and hence fix python Deprecation warnings which will be problematic in python 3.8. (Bitbake rev: c1fcc46e2498ddd41425d8756754f814d682aba3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/fetch2/git.py4
-rw-r--r--bitbake/lib/bb/fetch2/wget.py24
-rw-r--r--bitbake/lib/bb/monitordisk.py12
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py18
-rw-r--r--bitbake/lib/bb/providers.py4
-rw-r--r--bitbake/lib/bb/siggen.py2
-rw-r--r--bitbake/lib/bs4/dammit.py12
-rw-r--r--bitbake/lib/bs4/element.py8
8 files changed, 42 insertions, 42 deletions
diff --git a/bitbake/lib/bb/fetch2/git.py b/bitbake/lib/bb/fetch2/git.py
index 59a2ee8f80..c3c089233b 100644
--- a/bitbake/lib/bb/fetch2/git.py
+++ b/bitbake/lib/bb/fetch2/git.py
@@ -615,7 +615,7 @@ class Git(FetchMethod):
615 """ 615 """
616 pupver = ('', '') 616 pupver = ('', '')
617 617
618 tagregex = re.compile(d.getVar('UPSTREAM_CHECK_GITTAGREGEX') or "(?P<pver>([0-9][\.|_]?)+)") 618 tagregex = re.compile(d.getVar('UPSTREAM_CHECK_GITTAGREGEX') or r"(?P<pver>([0-9][\.|_]?)+)")
619 try: 619 try:
620 output = self._lsremote(ud, d, "refs/tags/*") 620 output = self._lsremote(ud, d, "refs/tags/*")
621 except (bb.fetch2.FetchError, bb.fetch2.NetworkAccess) as e: 621 except (bb.fetch2.FetchError, bb.fetch2.NetworkAccess) as e:
@@ -630,7 +630,7 @@ class Git(FetchMethod):
630 630
631 tag_head = line.split("/")[-1] 631 tag_head = line.split("/")[-1]
632 # Ignore non-released branches 632 # Ignore non-released branches
633 m = re.search("(alpha|beta|rc|final)+", tag_head) 633 m = re.search(r"(alpha|beta|rc|final)+", tag_head)
634 if m: 634 if m:
635 continue 635 continue
636 636
diff --git a/bitbake/lib/bb/fetch2/wget.py b/bitbake/lib/bb/fetch2/wget.py
index 1237e56098..e2037511da 100644
--- a/bitbake/lib/bb/fetch2/wget.py
+++ b/bitbake/lib/bb/fetch2/wget.py
@@ -481,7 +481,7 @@ class Wget(FetchMethod):
481 version_dir = ['', '', ''] 481 version_dir = ['', '', '']
482 version = ['', '', ''] 482 version = ['', '', '']
483 483
484 dirver_regex = re.compile("(?P<pfx>\D*)(?P<ver>(\d+[\.\-_])+(\d+))") 484 dirver_regex = re.compile(r"(?P<pfx>\D*)(?P<ver>(\d+[\.\-_])+(\d+))")
485 s = dirver_regex.search(dirver) 485 s = dirver_regex.search(dirver)
486 if s: 486 if s:
487 version_dir[1] = s.group('ver') 487 version_dir[1] = s.group('ver')
@@ -541,26 +541,26 @@ class Wget(FetchMethod):
541 gst-fluendo-mp3 541 gst-fluendo-mp3
542 """ 542 """
543 # match most patterns which uses "-" as separator to version digits 543 # match most patterns which uses "-" as separator to version digits
544 pn_prefix1 = "[a-zA-Z][a-zA-Z0-9]*([-_][a-zA-Z]\w+)*\+?[-_]" 544 pn_prefix1 = r"[a-zA-Z][a-zA-Z0-9]*([-_][a-zA-Z]\w+)*\+?[-_]"
545 # a loose pattern such as for unzip552.tar.gz 545 # a loose pattern such as for unzip552.tar.gz
546 pn_prefix2 = "[a-zA-Z]+" 546 pn_prefix2 = r"[a-zA-Z]+"
547 # a loose pattern such as for 80325-quicky-0.4.tar.gz 547 # a loose pattern such as for 80325-quicky-0.4.tar.gz
548 pn_prefix3 = "[0-9]+[-]?[a-zA-Z]+" 548 pn_prefix3 = r"[0-9]+[-]?[a-zA-Z]+"
549 # Save the Package Name (pn) Regex for use later 549 # Save the Package Name (pn) Regex for use later
550 pn_regex = "(%s|%s|%s)" % (pn_prefix1, pn_prefix2, pn_prefix3) 550 pn_regex = r"(%s|%s|%s)" % (pn_prefix1, pn_prefix2, pn_prefix3)
551 551
552 # match version 552 # match version
553 pver_regex = "(([A-Z]*\d+[a-zA-Z]*[\.\-_]*)+)" 553 pver_regex = r"(([A-Z]*\d+[a-zA-Z]*[\.\-_]*)+)"
554 554
555 # match arch 555 # match arch
556 parch_regex = "-source|_all_" 556 parch_regex = "-source|_all_"
557 557
558 # src.rpm extension was added only for rpm package. Can be removed if the rpm 558 # src.rpm extension was added only for rpm package. Can be removed if the rpm
559 # packaged will always be considered as having to be manually upgraded 559 # packaged will always be considered as having to be manually upgraded
560 psuffix_regex = "(tar\.gz|tgz|tar\.bz2|zip|xz|tar\.lz|rpm|bz2|orig\.tar\.gz|tar\.xz|src\.tar\.gz|src\.tgz|svnr\d+\.tar\.bz2|stable\.tar\.gz|src\.rpm)" 560 psuffix_regex = r"(tar\.gz|tgz|tar\.bz2|zip|xz|tar\.lz|rpm|bz2|orig\.tar\.gz|tar\.xz|src\.tar\.gz|src\.tgz|svnr\d+\.tar\.bz2|stable\.tar\.gz|src\.rpm)"
561 561
562 # match name, version and archive type of a package 562 # match name, version and archive type of a package
563 package_regex_comp = re.compile("(?P<name>%s?\.?v?)(?P<pver>%s)(?P<arch>%s)?[\.-](?P<type>%s$)" 563 package_regex_comp = re.compile(r"(?P<name>%s?\.?v?)(?P<pver>%s)(?P<arch>%s)?[\.-](?P<type>%s$)"
564 % (pn_regex, pver_regex, parch_regex, psuffix_regex)) 564 % (pn_regex, pver_regex, parch_regex, psuffix_regex))
565 self.suffix_regex_comp = re.compile(psuffix_regex) 565 self.suffix_regex_comp = re.compile(psuffix_regex)
566 566
@@ -572,7 +572,7 @@ class Wget(FetchMethod):
572 version = self._parse_path(package_regex_comp, package) 572 version = self._parse_path(package_regex_comp, package)
573 if version: 573 if version:
574 package_custom_regex_comp = re.compile( 574 package_custom_regex_comp = re.compile(
575 "(?P<name>%s)(?P<pver>%s)(?P<arch>%s)?[\.-](?P<type>%s)" % 575 r"(?P<name>%s)(?P<pver>%s)(?P<arch>%s)?[\.-](?P<type>%s)" %
576 (re.escape(version[0]), pver_regex, parch_regex, psuffix_regex)) 576 (re.escape(version[0]), pver_regex, parch_regex, psuffix_regex))
577 else: 577 else:
578 package_custom_regex_comp = None 578 package_custom_regex_comp = None
@@ -589,7 +589,7 @@ class Wget(FetchMethod):
589 current_version = ['', d.getVar('PV'), ''] 589 current_version = ['', d.getVar('PV'), '']
590 590
591 """possible to have no version in pkg name, such as spectrum-fw""" 591 """possible to have no version in pkg name, such as spectrum-fw"""
592 if not re.search("\d+", package): 592 if not re.search(r"\d+", package):
593 current_version[1] = re.sub('_', '.', current_version[1]) 593 current_version[1] = re.sub('_', '.', current_version[1])
594 current_version[1] = re.sub('-', '.', current_version[1]) 594 current_version[1] = re.sub('-', '.', current_version[1])
595 return (current_version[1], '') 595 return (current_version[1], '')
@@ -607,13 +607,13 @@ class Wget(FetchMethod):
607 607
608 # search for version matches on folders inside the path, like: 608 # search for version matches on folders inside the path, like:
609 # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz 609 # "5.7" in http://download.gnome.org/sources/${PN}/5.7/${PN}-${PV}.tar.gz
610 dirver_regex = re.compile("(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/") 610 dirver_regex = re.compile(r"(?P<dirver>[^/]*(\d+\.)*\d+([-_]r\d+)*)/")
611 m = dirver_regex.search(path) 611 m = dirver_regex.search(path)
612 if m: 612 if m:
613 pn = d.getVar('PN') 613 pn = d.getVar('PN')
614 dirver = m.group('dirver') 614 dirver = m.group('dirver')
615 615
616 dirver_pn_regex = re.compile("%s\d?" % (re.escape(pn))) 616 dirver_pn_regex = re.compile(r"%s\d?" % (re.escape(pn)))
617 if not dirver_pn_regex.search(dirver): 617 if not dirver_pn_regex.search(dirver):
618 return (self._check_latest_version_by_dir(dirver, 618 return (self._check_latest_version_by_dir(dirver,
619 package, package_regex, current_version, ud, d), '') 619 package, package_regex, current_version, ud, d), '')
diff --git a/bitbake/lib/bb/monitordisk.py b/bitbake/lib/bb/monitordisk.py
index 833cd3d344..2ad1e61562 100644
--- a/bitbake/lib/bb/monitordisk.py
+++ b/bitbake/lib/bb/monitordisk.py
@@ -28,16 +28,16 @@ def convertGMK(unit):
28 28
29 """ Convert the space unit G, M, K, the unit is case-insensitive """ 29 """ Convert the space unit G, M, K, the unit is case-insensitive """
30 30
31 unitG = re.match('([1-9][0-9]*)[gG]\s?$', unit) 31 unitG = re.match(r'([1-9][0-9]*)[gG]\s?$', unit)
32 if unitG: 32 if unitG:
33 return int(unitG.group(1)) * (1024 ** 3) 33 return int(unitG.group(1)) * (1024 ** 3)
34 unitM = re.match('([1-9][0-9]*)[mM]\s?$', unit) 34 unitM = re.match(r'([1-9][0-9]*)[mM]\s?$', unit)
35 if unitM: 35 if unitM:
36 return int(unitM.group(1)) * (1024 ** 2) 36 return int(unitM.group(1)) * (1024 ** 2)
37 unitK = re.match('([1-9][0-9]*)[kK]\s?$', unit) 37 unitK = re.match(r'([1-9][0-9]*)[kK]\s?$', unit)
38 if unitK: 38 if unitK:
39 return int(unitK.group(1)) * 1024 39 return int(unitK.group(1)) * 1024
40 unitN = re.match('([1-9][0-9]*)\s?$', unit) 40 unitN = re.match(r'([1-9][0-9]*)\s?$', unit)
41 if unitN: 41 if unitN:
42 return int(unitN.group(1)) 42 return int(unitN.group(1))
43 else: 43 else:
@@ -83,7 +83,7 @@ def getDiskData(BBDirs, configuration):
83 for pathSpaceInode in BBDirs.split(): 83 for pathSpaceInode in BBDirs.split():
84 # The input format is: "dir,space,inode", dir is a must, space 84 # The input format is: "dir,space,inode", dir is a must, space
85 # and inode are optional 85 # and inode are optional
86 pathSpaceInodeRe = re.match('([^,]*),([^,]*),([^,]*),?(.*)', pathSpaceInode) 86 pathSpaceInodeRe = re.match(r'([^,]*),([^,]*),([^,]*),?(.*)', pathSpaceInode)
87 if not pathSpaceInodeRe: 87 if not pathSpaceInodeRe:
88 printErr("Invalid value in BB_DISKMON_DIRS: %s" % pathSpaceInode) 88 printErr("Invalid value in BB_DISKMON_DIRS: %s" % pathSpaceInode)
89 return None 89 return None
@@ -147,7 +147,7 @@ def getInterval(configuration):
147 else: 147 else:
148 # The disk space or inode interval is optional, but it should 148 # The disk space or inode interval is optional, but it should
149 # have a correct value once it is specified 149 # have a correct value once it is specified
150 intervalRe = re.match('([^,]*),?\s*(.*)', interval) 150 intervalRe = re.match(r'([^,]*),?\s*(.*)', interval)
151 if intervalRe: 151 if intervalRe:
152 intervalSpace = intervalRe.group(1) 152 intervalSpace = intervalRe.group(1)
153 if intervalSpace: 153 if intervalSpace:
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index f3bf4aa529..9dba5f2334 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -38,15 +38,15 @@ from .ConfHandler import include, init
38# For compatibility 38# For compatibility
39bb.deprecate_import(__name__, "bb.parse", ["vars_from_file"]) 39bb.deprecate_import(__name__, "bb.parse", ["vars_from_file"])
40 40
41__func_start_regexp__ = re.compile( r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" ) 41__func_start_regexp__ = re.compile(r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" )
42__inherit_regexp__ = re.compile( r"inherit\s+(.+)" ) 42__inherit_regexp__ = re.compile(r"inherit\s+(.+)" )
43__export_func_regexp__ = re.compile( r"EXPORT_FUNCTIONS\s+(.+)" ) 43__export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" )
44__addtask_regexp__ = re.compile("addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*") 44__addtask_regexp__ = re.compile(r"addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*")
45__deltask_regexp__ = re.compile("deltask\s+(?P<func>\w+)") 45__deltask_regexp__ = re.compile(r"deltask\s+(?P<func>\w+)")
46__addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" ) 46__addhandler_regexp__ = re.compile(r"addhandler\s+(.+)" )
47__def_regexp__ = re.compile( r"def\s+(\w+).*:" ) 47__def_regexp__ = re.compile(r"def\s+(\w+).*:" )
48__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)|(^#)" ) 48__python_func_regexp__ = re.compile(r"(\s+.*)|(^$)|(^#)" )
49__python_tab_regexp__ = re.compile(" *\t") 49__python_tab_regexp__ = re.compile(r" *\t")
50 50
51__infunc__ = [] 51__infunc__ = []
52__inpython__ = False 52__inpython__ = False
diff --git a/bitbake/lib/bb/providers.py b/bitbake/lib/bb/providers.py
index c2aa98c065..f496d84d12 100644
--- a/bitbake/lib/bb/providers.py
+++ b/bitbake/lib/bb/providers.py
@@ -129,7 +129,7 @@ def findPreferredProvider(pn, cfgData, dataCache, pkg_pn = None, item = None):
129 preferred_v = cfgData.getVar("PREFERRED_VERSION") 129 preferred_v = cfgData.getVar("PREFERRED_VERSION")
130 130
131 if preferred_v: 131 if preferred_v:
132 m = re.match('(\d+:)*(.*)(_.*)*', preferred_v) 132 m = re.match(r'(\d+:)*(.*)(_.*)*', preferred_v)
133 if m: 133 if m:
134 if m.group(1): 134 if m.group(1):
135 preferred_e = m.group(1)[:-1] 135 preferred_e = m.group(1)[:-1]
@@ -384,7 +384,7 @@ def getRuntimeProviders(dataCache, rdepend):
384 384
385 # Only search dynamic packages if we can't find anything in other variables 385 # Only search dynamic packages if we can't find anything in other variables
386 for pattern in dataCache.packages_dynamic: 386 for pattern in dataCache.packages_dynamic:
387 pattern = pattern.replace('+', "\+") 387 pattern = pattern.replace(r'+', r"\+")
388 if pattern in regexp_cache: 388 if pattern in regexp_cache:
389 regexp = regexp_cache[pattern] 389 regexp = regexp_cache[pattern]
390 else: 390 else:
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index 66aea79355..03aa08bb94 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -90,7 +90,7 @@ class SignatureGeneratorBasic(SignatureGenerator):
90 self.taints = {} 90 self.taints = {}
91 self.gendeps = {} 91 self.gendeps = {}
92 self.lookupcache = {} 92 self.lookupcache = {}
93 self.pkgnameextract = re.compile("(?P<fn>.*)\..*") 93 self.pkgnameextract = re.compile(r"(?P<fn>.*)\..*")
94 self.basewhitelist = set((data.getVar("BB_HASHBASE_WHITELIST") or "").split()) 94 self.basewhitelist = set((data.getVar("BB_HASHBASE_WHITELIST") or "").split())
95 self.taskwhitelist = None 95 self.taskwhitelist = None
96 self.init_rundepcheck(data) 96 self.init_rundepcheck(data)
diff --git a/bitbake/lib/bs4/dammit.py b/bitbake/lib/bs4/dammit.py
index 68d419feb5..805aa908a5 100644
--- a/bitbake/lib/bs4/dammit.py
+++ b/bitbake/lib/bs4/dammit.py
@@ -45,9 +45,9 @@ except ImportError:
45 pass 45 pass
46 46
47xml_encoding_re = re.compile( 47xml_encoding_re = re.compile(
48 '^<\?.*encoding=[\'"](.*?)[\'"].*\?>'.encode(), re.I) 48 r'^<\?.*encoding=[\'"](.*?)[\'"].*\?>'.encode(), re.I)
49html_meta_re = re.compile( 49html_meta_re = re.compile(
50 '<\s*meta[^>]+charset\s*=\s*["\']?([^>]*?)[ /;\'">]'.encode(), re.I) 50 r'<\s*meta[^>]+charset\s*=\s*["\']?([^>]*?)[ /;\'">]'.encode(), re.I)
51 51
52class EntitySubstitution(object): 52class EntitySubstitution(object):
53 53
@@ -80,11 +80,11 @@ class EntitySubstitution(object):
80 ">": "gt", 80 ">": "gt",
81 } 81 }
82 82
83 BARE_AMPERSAND_OR_BRACKET = re.compile("([<>]|" 83 BARE_AMPERSAND_OR_BRACKET = re.compile(r"([<>]|"
84 "&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)" 84 r"&(?!#\d+;|#x[0-9a-fA-F]+;|\w+;)"
85 ")") 85 r")")
86 86
87 AMPERSAND_OR_BRACKET = re.compile("([<>&])") 87 AMPERSAND_OR_BRACKET = re.compile(r"([<>&])")
88 88
89 @classmethod 89 @classmethod
90 def _substitute_html_entity(cls, matchobj): 90 def _substitute_html_entity(cls, matchobj):
diff --git a/bitbake/lib/bs4/element.py b/bitbake/lib/bs4/element.py
index 0c30759ffc..3775a60458 100644
--- a/bitbake/lib/bs4/element.py
+++ b/bitbake/lib/bs4/element.py
@@ -10,7 +10,7 @@ from bs4.dammit import EntitySubstitution
10DEFAULT_OUTPUT_ENCODING = "utf-8" 10DEFAULT_OUTPUT_ENCODING = "utf-8"
11PY3K = (sys.version_info[0] > 2) 11PY3K = (sys.version_info[0] > 2)
12 12
13whitespace_re = re.compile("\s+") 13whitespace_re = re.compile(r"\s+")
14 14
15def _alias(attr): 15def _alias(attr):
16 """Alias one attribute name to another for backward compatibility""" 16 """Alias one attribute name to another for backward compatibility"""
@@ -67,7 +67,7 @@ class ContentMetaAttributeValue(AttributeValueWithCharsetSubstitution):
67 The value of the 'content' attribute will be one of these objects. 67 The value of the 'content' attribute will be one of these objects.
68 """ 68 """
69 69
70 CHARSET_RE = re.compile("((^|;)\s*charset=)([^;]*)", re.M) 70 CHARSET_RE = re.compile(r"((^|;)\s*charset=)([^;]*)", re.M)
71 71
72 def __new__(cls, original_value): 72 def __new__(cls, original_value):
73 match = cls.CHARSET_RE.search(original_value) 73 match = cls.CHARSET_RE.search(original_value)
@@ -580,7 +580,7 @@ class PageElement(object):
580 580
581 # Methods for supporting CSS selectors. 581 # Methods for supporting CSS selectors.
582 582
583 tag_name_re = re.compile('^[a-zA-Z0-9][-.a-zA-Z0-9:_]*$') 583 tag_name_re = re.compile(r'^[a-zA-Z0-9][-.a-zA-Z0-9:_]*$')
584 584
585 # /^([a-zA-Z0-9][-.a-zA-Z0-9:_]*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/ 585 # /^([a-zA-Z0-9][-.a-zA-Z0-9:_]*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/
586 # \---------------------------/ \---/\-------------/ \-------/ 586 # \---------------------------/ \---/\-------------/ \-------/
@@ -1364,7 +1364,7 @@ class Tag(PageElement):
1364 if tag_name == '': 1364 if tag_name == '':
1365 raise ValueError( 1365 raise ValueError(
1366 "A pseudo-class must be prefixed with a tag name.") 1366 "A pseudo-class must be prefixed with a tag name.")
1367 pseudo_attributes = re.match('([a-zA-Z\d-]+)\(([a-zA-Z\d]+)\)', pseudo) 1367 pseudo_attributes = re.match(r'([a-zA-Z\d-]+)\(([a-zA-Z\d]+)\)', pseudo)
1368 found = [] 1368 found = []
1369 if pseudo_attributes is None: 1369 if pseudo_attributes is None:
1370 pseudo_type = pseudo 1370 pseudo_type = pseudo