summaryrefslogtreecommitdiff
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/COW.py6
-rw-r--r--bitbake/lib/bb/cooker.py18
-rw-r--r--bitbake/lib/bb/fetch/__init__.py2
-rw-r--r--bitbake/lib/bb/parse/ast.py13
-rw-r--r--bitbake/lib/bb/runqueue.py2
-rw-r--r--bitbake/lib/bb/shell.py9
-rw-r--r--bitbake/lib/bb/ui/knotty.py2
-rw-r--r--bitbake/lib/bb/ui/ncurses.py2
-rw-r--r--bitbake/lib/bb/utils.py4
9 files changed, 30 insertions, 28 deletions
diff --git a/bitbake/lib/bb/COW.py b/bitbake/lib/bb/COW.py
index 23a2cae2b..6917ec378 100644
--- a/bitbake/lib/bb/COW.py
+++ b/bitbake/lib/bb/COW.py
@@ -82,7 +82,7 @@ class COWDictMeta(COWMeta):
print("Warning: Doing a copy because %s is a mutable type." % key, file=cls.__warn__)
try:
value = value.copy()
- except AttributeError, e:
+ except AttributeError as e:
value = copy.copy(value)
setattr(cls, nkey, value)
return value
@@ -106,7 +106,7 @@ class COWDictMeta(COWMeta):
raise AttributeError("key %s does not exist." % key)
return value
- except AttributeError, e:
+ except AttributeError as e:
if not default is cls.__getmarker__:
return default
@@ -239,7 +239,7 @@ if __name__ == "__main__":
try:
b['dict2']
- except KeyError, e:
+ except KeyError as e:
print("Okay!")
a['set'] = COWSetBase()
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 2b3dfb0cb..6884e9a55 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -173,7 +173,7 @@ class BBCooker:
except bb.build.FuncFailed:
bb.msg.error(bb.msg.domain.Build, "task stack execution failed")
raise
- except bb.build.EventException, e:
+ except bb.build.EventException as e:
event = e.args[1]
bb.msg.error(bb.msg.domain.Build, "%s event exception, aborting" % bb.event.getName(event))
raise
@@ -259,10 +259,10 @@ class BBCooker:
if fn:
try:
envdata = self.bb_cache.loadDataFull(fn, self.configuration.data)
- except IOError, e:
+ except IOError as e:
bb.msg.error(bb.msg.domain.Parsing, "Unable to read %s: %s" % (fn, e))
raise
- except Exception, e:
+ except Exception as e:
bb.msg.error(bb.msg.domain.Parsing, "%s" % e)
raise
@@ -272,7 +272,7 @@ class BBCooker:
with closing(StringIO()) as env:
data.emit_env(env, envdata, True)
bb.msg.plain(env.getvalue())
- except Exception, e:
+ except Exception as e:
bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
# emit the metadata which isnt valid shell
@@ -499,7 +499,7 @@ class BBCooker:
"""Drop off into a shell"""
try:
from bb import shell
- except ImportError, details:
+ except ImportError as details:
bb.msg.fatal(bb.msg.domain.Parsing, "Sorry, shell not available (%s)" % details )
else:
shell.start( self )
@@ -569,9 +569,9 @@ class BBCooker:
bb.event.fire(bb.event.ConfigParsed(), self.configuration.data)
- except IOError, e:
+ except IOError as e:
bb.msg.fatal(bb.msg.domain.Parsing, "Error when parsing %s: %s" % (files, str(e)))
- except bb.parse.ParseError, details:
+ except bb.parse.ParseError as details:
bb.msg.fatal(bb.msg.domain.Parsing, "Unable to parse %s (%s)" % (files, details) )
def handleCollections( self, collections ):
@@ -978,7 +978,7 @@ class CookerParser:
self.skipped += skipped
self.virtuals += virtuals
- except IOError, e:
+ except IOError as e:
self.error += 1
cooker.bb_cache.remove(f)
bb.msg.error(bb.msg.domain.Collection, "opening %s: %s" % (f, e))
@@ -987,7 +987,7 @@ class CookerParser:
cooker.bb_cache.remove(f)
cooker.bb_cache.sync()
raise
- except Exception, e:
+ except Exception as e:
self.error += 1
cooker.bb_cache.remove(f)
bb.msg.error(bb.msg.domain.Collection, "%s while parsing %s" % (e, f))
diff --git a/bitbake/lib/bb/fetch/__init__.py b/bitbake/lib/bb/fetch/__init__.py
index e87223ad6..651fea887 100644
--- a/bitbake/lib/bb/fetch/__init__.py
+++ b/bitbake/lib/bb/fetch/__init__.py
@@ -409,7 +409,7 @@ def runfetchcmd(cmd, d, quiet = False):
stdout_handle = os.popen(cmd + " 2>&1", "r")
output = ""
- while 1:
+ while True:
line = stdout_handle.readline()
if not line:
break
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index 4eabe5f2a..02d682d88 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -23,7 +23,7 @@
import bb, re, string
from bb import methodpool
-from itertools import chain
+import itertools
__word__ = re.compile(r"\S+")
__parsed_methods__ = bb.methodpool.get_parsed_dict()
@@ -31,7 +31,8 @@ _bbversions_re = re.compile(r"\[(?P<from>[0-9]+)-(?P<to>[0-9]+)\]")
class StatementGroup(list):
def eval(self, data):
- map(lambda x: x.eval(data), self)
+ for statement in self:
+ statement.eval(data)
class AstNode(object):
pass
@@ -341,7 +342,7 @@ def _expand_versions(versions):
versions = iter(versions)
while True:
try:
- version = versions.next()
+ version = next(versions)
except StopIteration:
break
@@ -351,7 +352,7 @@ def _expand_versions(versions):
else:
newversions = expand_one(version, int(range_ver.group("from")),
int(range_ver.group("to")))
- versions = chain(newversions, versions)
+ versions = itertools.chain(newversions, versions)
def multi_finalize(fn, d):
safe_d = d
@@ -417,7 +418,7 @@ def multi_finalize(fn, d):
safe_d.setVar("BBCLASSEXTEND", extended)
_create_variants(datastores, extended.split(), extendfunc)
- for variant, variant_d in datastores.items():
+ for variant, variant_d in datastores.iteritems():
if variant:
try:
finalize(fn, variant_d)
@@ -425,7 +426,7 @@ def multi_finalize(fn, d):
bb.data.setVar("__SKIPPED", True, variant_d)
if len(datastores) > 1:
- variants = filter(None, datastores.keys())
+ variants = filter(None, datastores.iterkeys())
safe_d.setVar("__VARIANTS", " ".join(variants))
datastores[""] = d
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 93fff5d27..a4aea6c00 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -928,7 +928,7 @@ class RunQueue:
while True:
task = None
if self.stats.active < self.number_tasks:
- task = self.sched.next()
+ task = next(self.sched)
if task is not None:
fn = self.taskData.fn_index[self.runq_fnid[task]]
diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py
index aeead679b..f9ca9d5bd 100644
--- a/bitbake/lib/bb/shell.py
+++ b/bitbake/lib/bb/shell.py
@@ -53,6 +53,7 @@ PROBLEMS:
##########################################################################
from __future__ import print_function
+from functools import reduce
try:
set
except NameError:
@@ -178,12 +179,12 @@ class BitBakeShellCommands:
print("ERROR: No Provider")
last_exception = Providers.NoProvider
- except runqueue.TaskFailure, fnids:
+ except runqueue.TaskFailure as fnids:
for fnid in fnids:
print("ERROR: '%s' failed" % td.fn_index[fnid])
last_exception = runqueue.TaskFailure
- except build.EventException, e:
+ except build.EventException as e:
print("ERROR: Couldn't build '%s'" % names)
last_exception = e
@@ -246,7 +247,7 @@ class BitBakeShellCommands:
cooker.buildFile(bf, cmd)
except parse.ParseError:
print("ERROR: Unable to open or parse '%s'" % bf)
- except build.EventException, e:
+ except build.EventException as e:
print("ERROR: Couldn't build '%s'" % name)
last_exception = e
@@ -644,7 +645,7 @@ def columnize( alist, width = 80 ):
return reduce(lambda line, word, width=width: '%s%s%s' %
(line,
' \n'[(len(line[line.rfind('\n')+1:])
- + len(word.split('\n',1)[0]
+ + len(word.split('\n', 1)[0]
) >= width)],
word),
alist
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index bfdcc5b49..f81759abf 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -123,7 +123,7 @@ def init(server, eventHandler):
x = event.sofar
y = event.total
if os.isatty(sys.stdout.fileno()):
- sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100//y ) )
+ sys.stdout.write("\rNOTE: Handling BitBake files: %s (%04d/%04d) [%2d %%]" % ( next(parsespin), x, y, x*100//y ) )
sys.stdout.flush()
else:
if x == 1:
diff --git a/bitbake/lib/bb/ui/ncurses.py b/bitbake/lib/bb/ui/ncurses.py
index e3bca2af8..81dcb1998 100644
--- a/bitbake/lib/bb/ui/ncurses.py
+++ b/bitbake/lib/bb/ui/ncurses.py
@@ -266,7 +266,7 @@ class NCursesUI:
mw.appendText("Parsing finished. %d cached, %d parsed, %d skipped, %d masked."
% ( event.cached, event.parsed, event.skipped, event.masked ))
else:
- mw.setStatus("Parsing: %s (%04d/%04d) [%2d %%]" % ( parsespin.next(), x, y, x*100/y ) )
+ mw.setStatus("Parsing: %s (%04d/%04d) [%2d %%]" % ( next(parsespin), x, y, x*100/y ) )
# if isinstance(event, bb.build.TaskFailed):
# if event.logfile:
# if data.getVar("BBINCLUDELOGS", d):
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index a7fb44d7d..c0cc9c6ea 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -326,7 +326,7 @@ def better_exec(code, context, text, realfile):
"""
import bb.parse
try:
- exec code in _context, context
+ exec(code, _context, context)
except:
(t, value, tb) = sys.exc_info()
@@ -349,7 +349,7 @@ def better_exec(code, context, text, realfile):
raise
def simple_exec(code, context):
- exec code in _context, context
+ exec(code, _context, context)
def better_eval(source, locals):
return eval(source, _context, locals)