mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 12:59:02 +02:00
scripts: python 3.12 regex
All the regexes throw a warning like this: WARNING: scripts/lib/recipetool/create_buildsys.py:140: SyntaxWarning: invalid escape sequence '\s' proj_re = re.compile('project\s*\(([^)]*)\)', re.IGNORECASE) Python 3 interprets string literals as Unicode strings, and therefore \s is treated as an escaped Unicode character which is not correct. Declaring the RegEx pattern as a raw string instead of unicode is required for Python 3. (From OE-Core rev: 24b0ba00d4f0b4d9834f7693ecb6032dfc534a80) Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
97eebe59d7
commit
605ef6f5a2
|
@ -483,7 +483,7 @@ def check_repo_clean(repodir):
|
||||||
exit if repo is dirty
|
exit if repo is dirty
|
||||||
"""
|
"""
|
||||||
output=runcmd("git status --porcelain", repodir)
|
output=runcmd("git status --porcelain", repodir)
|
||||||
r = re.compile('\?\? patch-.*/')
|
r = re.compile(r'\?\? patch-.*/')
|
||||||
dirtyout = [item for item in output.splitlines() if not r.match(item)]
|
dirtyout = [item for item in output.splitlines() if not r.match(item)]
|
||||||
if dirtyout:
|
if dirtyout:
|
||||||
logger.error("git repo %s is dirty, please fix it first", repodir)
|
logger.error("git repo %s is dirty, please fix it first", repodir)
|
||||||
|
|
|
@ -36,8 +36,8 @@ def bbvar_is_documented(var, documented_vars):
|
||||||
def collect_documented_vars(docfiles):
|
def collect_documented_vars(docfiles):
|
||||||
''' Walk the docfiles and collect the documented variables '''
|
''' Walk the docfiles and collect the documented variables '''
|
||||||
documented_vars = []
|
documented_vars = []
|
||||||
prog = re.compile(".*($|[^A-Z_])<glossentry id=\'var-")
|
prog = re.compile(r".*($|[^A-Z_])<glossentry id=\'var-")
|
||||||
var_prog = re.compile('<glossentry id=\'var-(.*)\'>')
|
var_prog = re.compile(r'<glossentry id=\'var-(.*)\'>')
|
||||||
for d in docfiles:
|
for d in docfiles:
|
||||||
with open(d) as f:
|
with open(d) as f:
|
||||||
documented_vars += var_prog.findall(f.read())
|
documented_vars += var_prog.findall(f.read())
|
||||||
|
@ -45,7 +45,7 @@ def collect_documented_vars(docfiles):
|
||||||
return documented_vars
|
return documented_vars
|
||||||
|
|
||||||
def bbvar_doctag(var, docconf):
|
def bbvar_doctag(var, docconf):
|
||||||
prog = re.compile('^%s\[doc\] *= *"(.*)"' % (var))
|
prog = re.compile(r'^%s\[doc\] *= *"(.*)"' % (var))
|
||||||
if docconf == "":
|
if docconf == "":
|
||||||
return "?"
|
return "?"
|
||||||
|
|
||||||
|
|
|
@ -81,19 +81,19 @@ skip_ext = [".html", ".patch", ".m4", ".diff"] + args.skip_ext
|
||||||
|
|
||||||
vars_re = {}
|
vars_re = {}
|
||||||
for exp in vars:
|
for exp in vars:
|
||||||
vars_re[exp] = (re.compile('((^|[#\'"\s\-\+])[A-Za-z0-9_\-:${}\.]+)_' + exp), r"\1:" + exp)
|
vars_re[exp] = (re.compile(r'((^|[#\'"\s\-\+])[A-Za-z0-9_\-:${}\.]+)_' + exp), r"\1:" + exp)
|
||||||
|
|
||||||
shortvars_re = {}
|
shortvars_re = {}
|
||||||
for exp in shortvars:
|
for exp in shortvars:
|
||||||
shortvars_re[exp] = (re.compile('((^|[#\'"\s\-\+])[A-Za-z0-9_\-:${}\.]+)_' + exp + '([\(\'"\s:])'), r"\1:" + exp + r"\3")
|
shortvars_re[exp] = (re.compile(r'((^|[#\'"\s\-\+])[A-Za-z0-9_\-:${}\.]+)_' + exp + r'([\(\'"\s:])'), r"\1:" + exp + r"\3")
|
||||||
|
|
||||||
package_re = {}
|
package_re = {}
|
||||||
for exp in packagevars:
|
for exp in packagevars:
|
||||||
package_re[exp] = (re.compile('(^|[#\'"\s\-\+]+)' + exp + '_' + '([$a-z"\'\s%\[<{\\\*].)'), r"\1" + exp + r":\2")
|
package_re[exp] = (re.compile(r'(^|[#\'"\s\-\+]+)' + exp + r'_' + r'([$a-z"\'\s%\[<{\\\*].)'), r"\1" + exp + r":\2")
|
||||||
|
|
||||||
# Other substitutions to make
|
# Other substitutions to make
|
||||||
subs = {
|
subs = {
|
||||||
'r = re.compile("([^:]+):\s*(.*)")' : 'r = re.compile("(^.+?):\s+(.*)")',
|
'r = re.compile(r"([^:]+):\s*(.*)")' : 'r = re.compile(r"(^.+?):\s+(.*)")',
|
||||||
"val = d.getVar('%s_%s' % (var, pkg))" : "val = d.getVar('%s:%s' % (var, pkg))",
|
"val = d.getVar('%s_%s' % (var, pkg))" : "val = d.getVar('%s:%s' % (var, pkg))",
|
||||||
"f.write('%s_%s: %s\\n' % (var, pkg, encode(val)))" : "f.write('%s:%s: %s\\n' % (var, pkg, encode(val)))",
|
"f.write('%s_%s: %s\\n' % (var, pkg, encode(val)))" : "f.write('%s:%s: %s\\n' % (var, pkg, encode(val)))",
|
||||||
"d.getVar('%s_%s' % (scriptlet_name, pkg))" : "d.getVar('%s:%s' % (scriptlet_name, pkg))",
|
"d.getVar('%s_%s' % (scriptlet_name, pkg))" : "d.getVar('%s:%s' % (scriptlet_name, pkg))",
|
||||||
|
|
|
@ -324,8 +324,8 @@ def get_signatures(builddir, failsafe=False, machine=None, extravars=None):
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
sig_regex = re.compile("^(?P<task>.*:.*):(?P<hash>.*) .$")
|
sig_regex = re.compile(r"^(?P<task>.*:.*):(?P<hash>.*) .$")
|
||||||
tune_regex = re.compile("(^|\s)SIGGEN_LOCKEDSIGS_t-(?P<tune>\S*)\s*=\s*")
|
tune_regex = re.compile(r"(^|\s)SIGGEN_LOCKEDSIGS_t-(?P<tune>\S*)\s*=\s*")
|
||||||
current_tune = None
|
current_tune = None
|
||||||
with open(sigs_file, 'r') as f:
|
with open(sigs_file, 'r') as f:
|
||||||
for line in f.readlines():
|
for line in f.readlines():
|
||||||
|
|
|
@ -1166,12 +1166,12 @@ def crunch_license(licfile):
|
||||||
# Note: these are carefully constructed!
|
# Note: these are carefully constructed!
|
||||||
license_title_re = re.compile(r'^#*\(? *(This is )?([Tt]he )?.{0,15} ?[Ll]icen[sc]e( \(.{1,10}\))?\)?[:\.]? ?#*$')
|
license_title_re = re.compile(r'^#*\(? *(This is )?([Tt]he )?.{0,15} ?[Ll]icen[sc]e( \(.{1,10}\))?\)?[:\.]? ?#*$')
|
||||||
license_statement_re = re.compile(r'^((This (project|software)|.{1,10}) is( free software)? (released|licen[sc]ed)|(Released|Licen[cs]ed)) under the .{1,10} [Ll]icen[sc]e:?$')
|
license_statement_re = re.compile(r'^((This (project|software)|.{1,10}) is( free software)? (released|licen[sc]ed)|(Released|Licen[cs]ed)) under the .{1,10} [Ll]icen[sc]e:?$')
|
||||||
copyright_re = re.compile('^ *[#\*]* *(Modified work |MIT LICENSED )?Copyright ?(\([cC]\))? .*$')
|
copyright_re = re.compile(r'^ *[#\*]* *(Modified work |MIT LICENSED )?Copyright ?(\([cC]\))? .*$')
|
||||||
disclaimer_re = re.compile('^ *\*? ?All [Rr]ights [Rr]eserved\.$')
|
disclaimer_re = re.compile(r'^ *\*? ?All [Rr]ights [Rr]eserved\.$')
|
||||||
email_re = re.compile('^.*<[\w\.-]*@[\w\.\-]*>$')
|
email_re = re.compile(r'^.*<[\w\.-]*@[\w\.\-]*>$')
|
||||||
header_re = re.compile('^(\/\**!?)? ?[\-=\*]* ?(\*\/)?$')
|
header_re = re.compile(r'^(\/\**!?)? ?[\-=\*]* ?(\*\/)?$')
|
||||||
tag_re = re.compile('^ *@?\(?([Ll]icense|MIT)\)?$')
|
tag_re = re.compile(r'^ *@?\(?([Ll]icense|MIT)\)?$')
|
||||||
url_re = re.compile('^ *[#\*]* *https?:\/\/[\w\.\/\-]+$')
|
url_re = re.compile(r'^ *[#\*]* *https?:\/\/[\w\.\/\-]+$')
|
||||||
|
|
||||||
lictext = []
|
lictext = []
|
||||||
with open(licfile, 'r', errors='surrogateescape') as f:
|
with open(licfile, 'r', errors='surrogateescape') as f:
|
||||||
|
|
|
@ -137,15 +137,15 @@ class CmakeRecipeHandler(RecipeHandler):
|
||||||
deps = []
|
deps = []
|
||||||
unmappedpkgs = []
|
unmappedpkgs = []
|
||||||
|
|
||||||
proj_re = re.compile('project\s*\(([^)]*)\)', re.IGNORECASE)
|
proj_re = re.compile(r'project\s*\(([^)]*)\)', re.IGNORECASE)
|
||||||
pkgcm_re = re.compile('pkg_check_modules\s*\(\s*[a-zA-Z0-9-_]+\s*(REQUIRED)?\s+([^)\s]+)\s*\)', re.IGNORECASE)
|
pkgcm_re = re.compile(r'pkg_check_modules\s*\(\s*[a-zA-Z0-9-_]+\s*(REQUIRED)?\s+([^)\s]+)\s*\)', re.IGNORECASE)
|
||||||
pkgsm_re = re.compile('pkg_search_module\s*\(\s*[a-zA-Z0-9-_]+\s*(REQUIRED)?((\s+[^)\s]+)+)\s*\)', re.IGNORECASE)
|
pkgsm_re = re.compile(r'pkg_search_module\s*\(\s*[a-zA-Z0-9-_]+\s*(REQUIRED)?((\s+[^)\s]+)+)\s*\)', re.IGNORECASE)
|
||||||
findpackage_re = re.compile('find_package\s*\(\s*([a-zA-Z0-9-_]+)\s*.*', re.IGNORECASE)
|
findpackage_re = re.compile(r'find_package\s*\(\s*([a-zA-Z0-9-_]+)\s*.*', re.IGNORECASE)
|
||||||
findlibrary_re = re.compile('find_library\s*\(\s*[a-zA-Z0-9-_]+\s*(NAMES\s+)?([a-zA-Z0-9-_ ]+)\s*.*')
|
findlibrary_re = re.compile(r'find_library\s*\(\s*[a-zA-Z0-9-_]+\s*(NAMES\s+)?([a-zA-Z0-9-_ ]+)\s*.*')
|
||||||
checklib_re = re.compile('check_library_exists\s*\(\s*([^\s)]+)\s*.*', re.IGNORECASE)
|
checklib_re = re.compile(r'check_library_exists\s*\(\s*([^\s)]+)\s*.*', re.IGNORECASE)
|
||||||
include_re = re.compile('include\s*\(\s*([^)\s]*)\s*\)', re.IGNORECASE)
|
include_re = re.compile(r'include\s*\(\s*([^)\s]*)\s*\)', re.IGNORECASE)
|
||||||
subdir_re = re.compile('add_subdirectory\s*\(\s*([^)\s]*)\s*([^)\s]*)\s*\)', re.IGNORECASE)
|
subdir_re = re.compile(r'add_subdirectory\s*\(\s*([^)\s]*)\s*([^)\s]*)\s*\)', re.IGNORECASE)
|
||||||
dep_re = re.compile('([^ ><=]+)( *[<>=]+ *[^ ><=]+)?')
|
dep_re = re.compile(r'([^ ><=]+)( *[<>=]+ *[^ ><=]+)?')
|
||||||
|
|
||||||
def find_cmake_package(pkg):
|
def find_cmake_package(pkg):
|
||||||
RecipeHandler.load_devel_filemap(tinfoil.config_data)
|
RecipeHandler.load_devel_filemap(tinfoil.config_data)
|
||||||
|
@ -423,16 +423,16 @@ class AutotoolsRecipeHandler(RecipeHandler):
|
||||||
'makeinfo': 'texinfo',
|
'makeinfo': 'texinfo',
|
||||||
}
|
}
|
||||||
|
|
||||||
pkg_re = re.compile('PKG_CHECK_MODULES\(\s*\[?[a-zA-Z0-9_]*\]?,\s*\[?([^,\]]*)\]?[),].*')
|
pkg_re = re.compile(r'PKG_CHECK_MODULES\(\s*\[?[a-zA-Z0-9_]*\]?,\s*\[?([^,\]]*)\]?[),].*')
|
||||||
pkgce_re = re.compile('PKG_CHECK_EXISTS\(\s*\[?([^,\]]*)\]?[),].*')
|
pkgce_re = re.compile(r'PKG_CHECK_EXISTS\(\s*\[?([^,\]]*)\]?[),].*')
|
||||||
lib_re = re.compile('AC_CHECK_LIB\(\s*\[?([^,\]]*)\]?,.*')
|
lib_re = re.compile(r'AC_CHECK_LIB\(\s*\[?([^,\]]*)\]?,.*')
|
||||||
libx_re = re.compile('AX_CHECK_LIBRARY\(\s*\[?[^,\]]*\]?,\s*\[?([^,\]]*)\]?,\s*\[?([a-zA-Z0-9-]*)\]?,.*')
|
libx_re = re.compile(r'AX_CHECK_LIBRARY\(\s*\[?[^,\]]*\]?,\s*\[?([^,\]]*)\]?,\s*\[?([a-zA-Z0-9-]*)\]?,.*')
|
||||||
progs_re = re.compile('_PROGS?\(\s*\[?[a-zA-Z0-9_]*\]?,\s*\[?([^,\]]*)\]?[),].*')
|
progs_re = re.compile(r'_PROGS?\(\s*\[?[a-zA-Z0-9_]*\]?,\s*\[?([^,\]]*)\]?[),].*')
|
||||||
dep_re = re.compile('([^ ><=]+)( [<>=]+ [^ ><=]+)?')
|
dep_re = re.compile(r'([^ ><=]+)( [<>=]+ [^ ><=]+)?')
|
||||||
ac_init_re = re.compile('AC_INIT\(\s*([^,]+),\s*([^,]+)[,)].*')
|
ac_init_re = re.compile(r'AC_INIT\(\s*([^,]+),\s*([^,]+)[,)].*')
|
||||||
am_init_re = re.compile('AM_INIT_AUTOMAKE\(\s*([^,]+),\s*([^,]+)[,)].*')
|
am_init_re = re.compile(r'AM_INIT_AUTOMAKE\(\s*([^,]+),\s*([^,]+)[,)].*')
|
||||||
define_re = re.compile('\s*(m4_)?define\(\s*([^,]+),\s*([^,]+)\)')
|
define_re = re.compile(r'\s*(m4_)?define\(\s*([^,]+),\s*([^,]+)\)')
|
||||||
version_re = re.compile('([0-9.]+)')
|
version_re = re.compile(r'([0-9.]+)')
|
||||||
|
|
||||||
defines = {}
|
defines = {}
|
||||||
def subst_defines(value):
|
def subst_defines(value):
|
||||||
|
|
|
@ -53,7 +53,7 @@ def check(args):
|
||||||
cmd = ['bitbake', '--dry-run', '--runall=build'] + args.target
|
cmd = ['bitbake', '--dry-run', '--runall=build'] + args.target
|
||||||
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env)
|
output = subprocess.check_output(cmd, stderr=subprocess.STDOUT, env=env)
|
||||||
|
|
||||||
task_re = re.compile('NOTE: Running setscene task [0-9]+ of [0-9]+ \(([^)]+)\)')
|
task_re = re.compile(r'NOTE: Running setscene task [0-9]+ of [0-9]+ \(([^)]+)\)')
|
||||||
tasks = []
|
tasks = []
|
||||||
for line in output.decode('utf-8').splitlines():
|
for line in output.decode('utf-8').splitlines():
|
||||||
res = task_re.match(line)
|
res = task_re.match(line)
|
||||||
|
|
|
@ -296,7 +296,7 @@ def package_info(args):
|
||||||
extra = ''
|
extra = ''
|
||||||
for line in f:
|
for line in f:
|
||||||
for var in vars:
|
for var in vars:
|
||||||
m = re.match(var + '(?::\S+)?:\s*(.+?)\s*$', line)
|
m = re.match(var + r'(?::\S+)?:\s*(.+?)\s*$', line)
|
||||||
if m:
|
if m:
|
||||||
vals[var] = m.group(1)
|
vals[var] = m.group(1)
|
||||||
pkg_version = vals['PKGV'] or ''
|
pkg_version = vals['PKGV'] or ''
|
||||||
|
|
|
@ -29,7 +29,7 @@ for arg in sys.argv[1:]:
|
||||||
args.append(arg)
|
args.append(arg)
|
||||||
|
|
||||||
# Regex for removing version specs after dependency items
|
# Regex for removing version specs after dependency items
|
||||||
verregex = re.compile(' \([=<>]* [^ )]*\)')
|
verregex = re.compile(r' \([=<>]* [^ )]*\)')
|
||||||
|
|
||||||
pkg = ""
|
pkg = ""
|
||||||
ver = ""
|
ver = ""
|
||||||
|
|
|
@ -16,7 +16,7 @@ import argparse
|
||||||
import re
|
import re
|
||||||
import git
|
import git
|
||||||
|
|
||||||
re_prefix = re.compile("(\[.*\])", re.DOTALL)
|
re_prefix = re.compile(r"(\[.*\])", re.DOTALL)
|
||||||
|
|
||||||
def get_branch(filepath_repo, filepath_mbox, default_branch):
|
def get_branch(filepath_repo, filepath_mbox, default_branch):
|
||||||
branch = None
|
branch = None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user