mirror of
https://git.yoctoproject.org/poky
synced 2026-05-30 00:20:08 +00:00
bitbake: bitbake: Convert to python 3
Various misc changes to convert bitbake to python3 which don't warrant separation into separate commits. (Bitbake rev: d0f904d407f57998419bd9c305ce53e5eaa36b24) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
+10
-10
@@ -37,7 +37,7 @@ import errno
|
||||
import signal
|
||||
import ast
|
||||
import collections
|
||||
from commands import getstatusoutput
|
||||
from subprocess import getstatusoutput
|
||||
from contextlib import contextmanager
|
||||
from ctypes import cdll
|
||||
|
||||
@@ -76,7 +76,7 @@ def explode_version(s):
|
||||
r.append((0, int(m.group(1))))
|
||||
s = m.group(2)
|
||||
continue
|
||||
if s[0] in string.letters:
|
||||
if s[0] in string.ascii_letters:
|
||||
m = alpha_regexp.match(s)
|
||||
r.append((1, m.group(1)))
|
||||
s = m.group(2)
|
||||
@@ -588,7 +588,7 @@ def filter_environment(good_vars):
|
||||
"""
|
||||
|
||||
removed_vars = {}
|
||||
for key in os.environ.keys():
|
||||
for key in list(os.environ):
|
||||
if key in good_vars:
|
||||
continue
|
||||
|
||||
@@ -641,7 +641,7 @@ def empty_environment():
|
||||
"""
|
||||
Remove all variables from the environment.
|
||||
"""
|
||||
for s in os.environ.keys():
|
||||
for s in list(os.environ.keys()):
|
||||
os.unsetenv(s)
|
||||
del os.environ[s]
|
||||
|
||||
@@ -958,7 +958,7 @@ def contains(variable, checkvalues, truevalue, falsevalue, d):
|
||||
if not val:
|
||||
return falsevalue
|
||||
val = set(val.split())
|
||||
if isinstance(checkvalues, basestring):
|
||||
if isinstance(checkvalues, str):
|
||||
checkvalues = set(checkvalues.split())
|
||||
else:
|
||||
checkvalues = set(checkvalues)
|
||||
@@ -971,7 +971,7 @@ def contains_any(variable, checkvalues, truevalue, falsevalue, d):
|
||||
if not val:
|
||||
return falsevalue
|
||||
val = set(val.split())
|
||||
if isinstance(checkvalues, basestring):
|
||||
if isinstance(checkvalues, str):
|
||||
checkvalues = set(checkvalues.split())
|
||||
else:
|
||||
checkvalues = set(checkvalues)
|
||||
@@ -1040,7 +1040,7 @@ def exec_flat_python_func(func, *args, **kwargs):
|
||||
aidx += 1
|
||||
# Handle keyword arguments
|
||||
context.update(kwargs)
|
||||
funcargs.extend(['%s=%s' % (arg, arg) for arg in kwargs.iterkeys()])
|
||||
funcargs.extend(['%s=%s' % (arg, arg) for arg in kwargs.keys()])
|
||||
code = 'retval = %s(%s)' % (func, ', '.join(funcargs))
|
||||
comp = bb.utils.better_compile(code, '<string>', '<string>')
|
||||
bb.utils.better_exec(comp, context, code, '<string>')
|
||||
@@ -1127,7 +1127,7 @@ def edit_metadata(meta_lines, variables, varfunc, match_overrides=False):
|
||||
else:
|
||||
varset_new = varset_start
|
||||
|
||||
if isinstance(indent, (int, long)):
|
||||
if isinstance(indent, int):
|
||||
if indent == -1:
|
||||
indentspc = ' ' * (len(varset_new) + 2)
|
||||
else:
|
||||
@@ -1195,7 +1195,7 @@ def edit_metadata(meta_lines, variables, varfunc, match_overrides=False):
|
||||
in_var = None
|
||||
else:
|
||||
skip = False
|
||||
for (varname, var_re) in var_res.iteritems():
|
||||
for (varname, var_re) in var_res.items():
|
||||
res = var_re.match(line)
|
||||
if res:
|
||||
isfunc = varname.endswith('()')
|
||||
@@ -1373,7 +1373,7 @@ def get_file_layer(filename, d):
|
||||
# Use longest path so we handle nested layers
|
||||
matchlen = 0
|
||||
match = None
|
||||
for collection, regex in collection_res.iteritems():
|
||||
for collection, regex in collection_res.items():
|
||||
if len(regex) > matchlen and re.match(regex, path):
|
||||
matchlen = len(regex)
|
||||
match = collection
|
||||
|
||||
Reference in New Issue
Block a user