diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-12 08:30:35 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-06-02 08:24:02 +0100 |
commit | 0f2c59367a649de5f57acdccfb4f1fdba9cde730 (patch) | |
tree | 7a3558a3e08e690fbb0b5bdc4044316f9ab4bbcb /bitbake/lib/bb/utils.py | |
parent | ef1df516512587ad415f76a9626620992d660e45 (diff) | |
download | poky-0f2c59367a649de5f57acdccfb4f1fdba9cde730.tar.gz |
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>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r-- | bitbake/lib/bb/utils.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 588c192c08..138da44ef1 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -37,7 +37,7 @@ import errno | |||
37 | import signal | 37 | import signal |
38 | import ast | 38 | import ast |
39 | import collections | 39 | import collections |
40 | from commands import getstatusoutput | 40 | from subprocess import getstatusoutput |
41 | from contextlib import contextmanager | 41 | from contextlib import contextmanager |
42 | from ctypes import cdll | 42 | from ctypes import cdll |
43 | 43 | ||
@@ -76,7 +76,7 @@ def explode_version(s): | |||
76 | r.append((0, int(m.group(1)))) | 76 | r.append((0, int(m.group(1)))) |
77 | s = m.group(2) | 77 | s = m.group(2) |
78 | continue | 78 | continue |
79 | if s[0] in string.letters: | 79 | if s[0] in string.ascii_letters: |
80 | m = alpha_regexp.match(s) | 80 | m = alpha_regexp.match(s) |
81 | r.append((1, m.group(1))) | 81 | r.append((1, m.group(1))) |
82 | s = m.group(2) | 82 | s = m.group(2) |
@@ -588,7 +588,7 @@ def filter_environment(good_vars): | |||
588 | """ | 588 | """ |
589 | 589 | ||
590 | removed_vars = {} | 590 | removed_vars = {} |
591 | for key in os.environ.keys(): | 591 | for key in list(os.environ): |
592 | if key in good_vars: | 592 | if key in good_vars: |
593 | continue | 593 | continue |
594 | 594 | ||
@@ -641,7 +641,7 @@ def empty_environment(): | |||
641 | """ | 641 | """ |
642 | Remove all variables from the environment. | 642 | Remove all variables from the environment. |
643 | """ | 643 | """ |
644 | for s in os.environ.keys(): | 644 | for s in list(os.environ.keys()): |
645 | os.unsetenv(s) | 645 | os.unsetenv(s) |
646 | del os.environ[s] | 646 | del os.environ[s] |
647 | 647 | ||
@@ -958,7 +958,7 @@ def contains(variable, checkvalues, truevalue, falsevalue, d): | |||
958 | if not val: | 958 | if not val: |
959 | return falsevalue | 959 | return falsevalue |
960 | val = set(val.split()) | 960 | val = set(val.split()) |
961 | if isinstance(checkvalues, basestring): | 961 | if isinstance(checkvalues, str): |
962 | checkvalues = set(checkvalues.split()) | 962 | checkvalues = set(checkvalues.split()) |
963 | else: | 963 | else: |
964 | checkvalues = set(checkvalues) | 964 | checkvalues = set(checkvalues) |
@@ -971,7 +971,7 @@ def contains_any(variable, checkvalues, truevalue, falsevalue, d): | |||
971 | if not val: | 971 | if not val: |
972 | return falsevalue | 972 | return falsevalue |
973 | val = set(val.split()) | 973 | val = set(val.split()) |
974 | if isinstance(checkvalues, basestring): | 974 | if isinstance(checkvalues, str): |
975 | checkvalues = set(checkvalues.split()) | 975 | checkvalues = set(checkvalues.split()) |
976 | else: | 976 | else: |
977 | checkvalues = set(checkvalues) | 977 | checkvalues = set(checkvalues) |
@@ -1040,7 +1040,7 @@ def exec_flat_python_func(func, *args, **kwargs): | |||
1040 | aidx += 1 | 1040 | aidx += 1 |
1041 | # Handle keyword arguments | 1041 | # Handle keyword arguments |
1042 | context.update(kwargs) | 1042 | context.update(kwargs) |
1043 | funcargs.extend(['%s=%s' % (arg, arg) for arg in kwargs.iterkeys()]) | 1043 | funcargs.extend(['%s=%s' % (arg, arg) for arg in kwargs.keys()]) |
1044 | code = 'retval = %s(%s)' % (func, ', '.join(funcargs)) | 1044 | code = 'retval = %s(%s)' % (func, ', '.join(funcargs)) |
1045 | comp = bb.utils.better_compile(code, '<string>', '<string>') | 1045 | comp = bb.utils.better_compile(code, '<string>', '<string>') |
1046 | bb.utils.better_exec(comp, context, code, '<string>') | 1046 | bb.utils.better_exec(comp, context, code, '<string>') |
@@ -1127,7 +1127,7 @@ def edit_metadata(meta_lines, variables, varfunc, match_overrides=False): | |||
1127 | else: | 1127 | else: |
1128 | varset_new = varset_start | 1128 | varset_new = varset_start |
1129 | 1129 | ||
1130 | if isinstance(indent, (int, long)): | 1130 | if isinstance(indent, int): |
1131 | if indent == -1: | 1131 | if indent == -1: |
1132 | indentspc = ' ' * (len(varset_new) + 2) | 1132 | indentspc = ' ' * (len(varset_new) + 2) |
1133 | else: | 1133 | else: |
@@ -1195,7 +1195,7 @@ def edit_metadata(meta_lines, variables, varfunc, match_overrides=False): | |||
1195 | in_var = None | 1195 | in_var = None |
1196 | else: | 1196 | else: |
1197 | skip = False | 1197 | skip = False |
1198 | for (varname, var_re) in var_res.iteritems(): | 1198 | for (varname, var_re) in var_res.items(): |
1199 | res = var_re.match(line) | 1199 | res = var_re.match(line) |
1200 | if res: | 1200 | if res: |
1201 | isfunc = varname.endswith('()') | 1201 | isfunc = varname.endswith('()') |
@@ -1373,7 +1373,7 @@ def get_file_layer(filename, d): | |||
1373 | # Use longest path so we handle nested layers | 1373 | # Use longest path so we handle nested layers |
1374 | matchlen = 0 | 1374 | matchlen = 0 |
1375 | match = None | 1375 | match = None |
1376 | for collection, regex in collection_res.iteritems(): | 1376 | for collection, regex in collection_res.items(): |
1377 | if len(regex) > matchlen and re.match(regex, path): | 1377 | if len(regex) > matchlen and re.match(regex, path): |
1378 | matchlen = len(regex) | 1378 | matchlen = len(regex) |
1379 | match = collection | 1379 | match = collection |