Apply some 2to3 refactorings
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
This commit is contained in:
parent
20dc452614
commit
ef1de9ecaf
|
@ -200,7 +200,7 @@ Default BBFILES are the .bb files in the current directory.""")
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
return_value = ui_init(serverConnection.connection, serverConnection.events)
|
return_value = ui_init(serverConnection.connection, serverConnection.events)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
print "FATAL: Unable to start to '%s' UI: %s" % (ui, e)
|
print "FATAL: Unable to start to '%s' UI: %s" % (ui, e)
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
|
|
|
@ -48,7 +48,7 @@ class HTMLFormatter:
|
||||||
From pydoc... almost identical at least
|
From pydoc... almost identical at least
|
||||||
"""
|
"""
|
||||||
while pairs:
|
while pairs:
|
||||||
(a,b) = pairs[0]
|
(a, b) = pairs[0]
|
||||||
text = join(split(text, a), b)
|
text = join(split(text, a), b)
|
||||||
pairs = pairs[1:]
|
pairs = pairs[1:]
|
||||||
return text
|
return text
|
||||||
|
@ -87,7 +87,7 @@ class HTMLFormatter:
|
||||||
|
|
||||||
return txt + ",".join(txts)
|
return txt + ",".join(txts)
|
||||||
|
|
||||||
def groups(self,item):
|
def groups(self, item):
|
||||||
"""
|
"""
|
||||||
Create HTML to link to related groups
|
Create HTML to link to related groups
|
||||||
"""
|
"""
|
||||||
|
@ -99,12 +99,12 @@ class HTMLFormatter:
|
||||||
txt = "<p><b>See also:</b><br>"
|
txt = "<p><b>See also:</b><br>"
|
||||||
txts = []
|
txts = []
|
||||||
for group in item.groups():
|
for group in item.groups():
|
||||||
txts.append( """<a href="group%s.html">%s</a> """ % (group,group) )
|
txts.append( """<a href="group%s.html">%s</a> """ % (group, group) )
|
||||||
|
|
||||||
return txt + ",".join(txts)
|
return txt + ",".join(txts)
|
||||||
|
|
||||||
|
|
||||||
def createKeySite(self,item):
|
def createKeySite(self, item):
|
||||||
"""
|
"""
|
||||||
Create a site for a key. It contains the header/navigator, a heading,
|
Create a site for a key. It contains the header/navigator, a heading,
|
||||||
the description, links to related keys and to the groups.
|
the description, links to related keys and to the groups.
|
||||||
|
@ -149,8 +149,7 @@ class HTMLFormatter:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
groups = ""
|
groups = ""
|
||||||
sorted_groups = doc.groups()
|
sorted_groups = sorted(doc.groups())
|
||||||
sorted_groups.sort()
|
|
||||||
for group in sorted_groups:
|
for group in sorted_groups:
|
||||||
groups += """<a href="group%s.html">%s</a><br>""" % (group, group)
|
groups += """<a href="group%s.html">%s</a><br>""" % (group, group)
|
||||||
|
|
||||||
|
@ -185,8 +184,7 @@ class HTMLFormatter:
|
||||||
Create Overview of all avilable keys
|
Create Overview of all avilable keys
|
||||||
"""
|
"""
|
||||||
keys = ""
|
keys = ""
|
||||||
sorted_keys = doc.doc_keys()
|
sorted_keys = sorted(doc.doc_keys())
|
||||||
sorted_keys.sort()
|
|
||||||
for key in sorted_keys:
|
for key in sorted_keys:
|
||||||
keys += """<a href="key%s.html">%s</a><br>""" % (key, key)
|
keys += """<a href="key%s.html">%s</a><br>""" % (key, key)
|
||||||
|
|
||||||
|
@ -214,7 +212,7 @@ class HTMLFormatter:
|
||||||
description += "<h2 Description of Grozp %s</h2>" % gr
|
description += "<h2 Description of Grozp %s</h2>" % gr
|
||||||
description += _description
|
description += _description
|
||||||
|
|
||||||
items.sort(lambda x,y:cmp(x.name(),y.name()))
|
items.sort(lambda x, y:cmp(x.name(), y.name()))
|
||||||
for group in items:
|
for group in items:
|
||||||
groups += """<a href="key%s.html">%s</a><br>""" % (group.name(), group.name())
|
groups += """<a href="key%s.html">%s</a><br>""" % (group.name(), group.name())
|
||||||
|
|
||||||
|
@ -343,7 +341,7 @@ class DocumentationItem:
|
||||||
def addGroup(self, group):
|
def addGroup(self, group):
|
||||||
self._groups.append(group)
|
self._groups.append(group)
|
||||||
|
|
||||||
def addRelation(self,relation):
|
def addRelation(self, relation):
|
||||||
self._related.append(relation)
|
self._related.append(relation)
|
||||||
|
|
||||||
def sort(self):
|
def sort(self):
|
||||||
|
@ -396,7 +394,7 @@ class Documentation:
|
||||||
"""
|
"""
|
||||||
return self.__groups.keys()
|
return self.__groups.keys()
|
||||||
|
|
||||||
def group_content(self,group_name):
|
def group_content(self, group_name):
|
||||||
"""
|
"""
|
||||||
Return a list of keys/names that are in a specefic
|
Return a list of keys/names that are in a specefic
|
||||||
group or the empty list
|
group or the empty list
|
||||||
|
@ -412,7 +410,7 @@ def parse_cmdline(args):
|
||||||
Parse the CMD line and return the result as a n-tuple
|
Parse the CMD line and return the result as a n-tuple
|
||||||
"""
|
"""
|
||||||
|
|
||||||
parser = optparse.OptionParser( version = "Bitbake Documentation Tool Core version %s, %%prog version %s" % (bb.__version__,__version__))
|
parser = optparse.OptionParser( version = "Bitbake Documentation Tool Core version %s, %%prog version %s" % (bb.__version__, __version__))
|
||||||
usage = """%prog [options]
|
usage = """%prog [options]
|
||||||
|
|
||||||
Create a set of html pages (documentation) for a bitbake.conf....
|
Create a set of html pages (documentation) for a bitbake.conf....
|
||||||
|
@ -428,7 +426,7 @@ Create a set of html pages (documentation) for a bitbake.conf....
|
||||||
parser.add_option( "-D", "--debug", help = "Increase the debug level",
|
parser.add_option( "-D", "--debug", help = "Increase the debug level",
|
||||||
action = "count", dest = "debug", default = 0 )
|
action = "count", dest = "debug", default = 0 )
|
||||||
|
|
||||||
parser.add_option( "-v","--verbose", help = "output more chit-char to the terminal",
|
parser.add_option( "-v", "--verbose", help = "output more chit-char to the terminal",
|
||||||
action = "store_true", dest = "verbose", default = False )
|
action = "store_true", dest = "verbose", default = False )
|
||||||
|
|
||||||
options, args = parser.parse_args( sys.argv )
|
options, args = parser.parse_args( sys.argv )
|
||||||
|
@ -443,7 +441,7 @@ def main():
|
||||||
The main Method
|
The main Method
|
||||||
"""
|
"""
|
||||||
|
|
||||||
(config_file,output_dir) = parse_cmdline( sys.argv )
|
(config_file, output_dir) = parse_cmdline( sys.argv )
|
||||||
|
|
||||||
# right to let us load the file now
|
# right to let us load the file now
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -82,7 +82,7 @@ class COWDictMeta(COWMeta):
|
||||||
print("Warning: Doing a copy because %s is a mutable type." % key, file=cls.__warn__)
|
print("Warning: Doing a copy because %s is a mutable type." % key, file=cls.__warn__)
|
||||||
try:
|
try:
|
||||||
value = value.copy()
|
value = value.copy()
|
||||||
except AttributeError, e:
|
except AttributeError as e:
|
||||||
value = copy.copy(value)
|
value = copy.copy(value)
|
||||||
setattr(cls, nkey, value)
|
setattr(cls, nkey, value)
|
||||||
return value
|
return value
|
||||||
|
@ -106,7 +106,7 @@ class COWDictMeta(COWMeta):
|
||||||
raise AttributeError("key %s does not exist." % key)
|
raise AttributeError("key %s does not exist." % key)
|
||||||
|
|
||||||
return value
|
return value
|
||||||
except AttributeError, e:
|
except AttributeError as e:
|
||||||
if not default is cls.__getmarker__:
|
if not default is cls.__getmarker__:
|
||||||
return default
|
return default
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
try:
|
try:
|
||||||
b['dict2']
|
b['dict2']
|
||||||
except KeyError, e:
|
except KeyError as e:
|
||||||
print("Okay!")
|
print("Okay!")
|
||||||
|
|
||||||
a['set'] = COWSetBase()
|
a['set'] = COWSetBase()
|
||||||
|
|
|
@ -173,7 +173,7 @@ class BBCooker:
|
||||||
except bb.build.FuncFailed:
|
except bb.build.FuncFailed:
|
||||||
bb.msg.error(bb.msg.domain.Build, "task stack execution failed")
|
bb.msg.error(bb.msg.domain.Build, "task stack execution failed")
|
||||||
raise
|
raise
|
||||||
except bb.build.EventException, e:
|
except bb.build.EventException as e:
|
||||||
event = e.args[1]
|
event = e.args[1]
|
||||||
bb.msg.error(bb.msg.domain.Build, "%s event exception, aborting" % bb.event.getName(event))
|
bb.msg.error(bb.msg.domain.Build, "%s event exception, aborting" % bb.event.getName(event))
|
||||||
raise
|
raise
|
||||||
|
@ -259,10 +259,10 @@ class BBCooker:
|
||||||
if fn:
|
if fn:
|
||||||
try:
|
try:
|
||||||
envdata = self.bb_cache.loadDataFull(fn, self.configuration.data)
|
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))
|
bb.msg.error(bb.msg.domain.Parsing, "Unable to read %s: %s" % (fn, e))
|
||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
bb.msg.error(bb.msg.domain.Parsing, "%s" % e)
|
bb.msg.error(bb.msg.domain.Parsing, "%s" % e)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ class BBCooker:
|
||||||
with closing(StringIO()) as env:
|
with closing(StringIO()) as env:
|
||||||
data.emit_env(env, envdata, True)
|
data.emit_env(env, envdata, True)
|
||||||
bb.msg.plain(env.getvalue())
|
bb.msg.plain(env.getvalue())
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
|
bb.msg.fatal(bb.msg.domain.Parsing, "%s" % e)
|
||||||
|
|
||||||
# emit the metadata which isnt valid shell
|
# emit the metadata which isnt valid shell
|
||||||
|
@ -499,7 +499,7 @@ class BBCooker:
|
||||||
"""Drop off into a shell"""
|
"""Drop off into a shell"""
|
||||||
try:
|
try:
|
||||||
from bb import shell
|
from bb import shell
|
||||||
except ImportError, details:
|
except ImportError as details:
|
||||||
bb.msg.fatal(bb.msg.domain.Parsing, "Sorry, shell not available (%s)" % details )
|
bb.msg.fatal(bb.msg.domain.Parsing, "Sorry, shell not available (%s)" % details )
|
||||||
else:
|
else:
|
||||||
shell.start( self )
|
shell.start( self )
|
||||||
|
@ -569,9 +569,9 @@ class BBCooker:
|
||||||
bb.event.fire(bb.event.ConfigParsed(), self.configuration.data)
|
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)))
|
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) )
|
bb.msg.fatal(bb.msg.domain.Parsing, "Unable to parse %s (%s)" % (files, details) )
|
||||||
|
|
||||||
def handleCollections( self, collections ):
|
def handleCollections( self, collections ):
|
||||||
|
@ -978,7 +978,7 @@ class CookerParser:
|
||||||
self.skipped += skipped
|
self.skipped += skipped
|
||||||
self.virtuals += virtuals
|
self.virtuals += virtuals
|
||||||
|
|
||||||
except IOError, e:
|
except IOError as e:
|
||||||
self.error += 1
|
self.error += 1
|
||||||
cooker.bb_cache.remove(f)
|
cooker.bb_cache.remove(f)
|
||||||
bb.msg.error(bb.msg.domain.Collection, "opening %s: %s" % (f, e))
|
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.remove(f)
|
||||||
cooker.bb_cache.sync()
|
cooker.bb_cache.sync()
|
||||||
raise
|
raise
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
self.error += 1
|
self.error += 1
|
||||||
cooker.bb_cache.remove(f)
|
cooker.bb_cache.remove(f)
|
||||||
bb.msg.error(bb.msg.domain.Collection, "%s while parsing %s" % (e, f))
|
bb.msg.error(bb.msg.domain.Collection, "%s while parsing %s" % (e, f))
|
||||||
|
|
|
@ -409,7 +409,7 @@ def runfetchcmd(cmd, d, quiet = False):
|
||||||
stdout_handle = os.popen(cmd + " 2>&1", "r")
|
stdout_handle = os.popen(cmd + " 2>&1", "r")
|
||||||
output = ""
|
output = ""
|
||||||
|
|
||||||
while 1:
|
while True:
|
||||||
line = stdout_handle.readline()
|
line = stdout_handle.readline()
|
||||||
if not line:
|
if not line:
|
||||||
break
|
break
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
import bb, re, string
|
import bb, re, string
|
||||||
from bb import methodpool
|
from bb import methodpool
|
||||||
from itertools import chain
|
import itertools
|
||||||
|
|
||||||
__word__ = re.compile(r"\S+")
|
__word__ = re.compile(r"\S+")
|
||||||
__parsed_methods__ = bb.methodpool.get_parsed_dict()
|
__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):
|
class StatementGroup(list):
|
||||||
def eval(self, data):
|
def eval(self, data):
|
||||||
map(lambda x: x.eval(data), self)
|
for statement in self:
|
||||||
|
statement.eval(data)
|
||||||
|
|
||||||
class AstNode(object):
|
class AstNode(object):
|
||||||
pass
|
pass
|
||||||
|
@ -341,7 +342,7 @@ def _expand_versions(versions):
|
||||||
versions = iter(versions)
|
versions = iter(versions)
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
version = versions.next()
|
version = next(versions)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -351,7 +352,7 @@ def _expand_versions(versions):
|
||||||
else:
|
else:
|
||||||
newversions = expand_one(version, int(range_ver.group("from")),
|
newversions = expand_one(version, int(range_ver.group("from")),
|
||||||
int(range_ver.group("to")))
|
int(range_ver.group("to")))
|
||||||
versions = chain(newversions, versions)
|
versions = itertools.chain(newversions, versions)
|
||||||
|
|
||||||
def multi_finalize(fn, d):
|
def multi_finalize(fn, d):
|
||||||
safe_d = d
|
safe_d = d
|
||||||
|
@ -417,7 +418,7 @@ def multi_finalize(fn, d):
|
||||||
safe_d.setVar("BBCLASSEXTEND", extended)
|
safe_d.setVar("BBCLASSEXTEND", extended)
|
||||||
_create_variants(datastores, extended.split(), extendfunc)
|
_create_variants(datastores, extended.split(), extendfunc)
|
||||||
|
|
||||||
for variant, variant_d in datastores.items():
|
for variant, variant_d in datastores.iteritems():
|
||||||
if variant:
|
if variant:
|
||||||
try:
|
try:
|
||||||
finalize(fn, variant_d)
|
finalize(fn, variant_d)
|
||||||
|
@ -425,7 +426,7 @@ def multi_finalize(fn, d):
|
||||||
bb.data.setVar("__SKIPPED", True, variant_d)
|
bb.data.setVar("__SKIPPED", True, variant_d)
|
||||||
|
|
||||||
if len(datastores) > 1:
|
if len(datastores) > 1:
|
||||||
variants = filter(None, datastores.keys())
|
variants = filter(None, datastores.iterkeys())
|
||||||
safe_d.setVar("__VARIANTS", " ".join(variants))
|
safe_d.setVar("__VARIANTS", " ".join(variants))
|
||||||
|
|
||||||
datastores[""] = d
|
datastores[""] = d
|
||||||
|
|
|
@ -928,7 +928,7 @@ class RunQueue:
|
||||||
while True:
|
while True:
|
||||||
task = None
|
task = None
|
||||||
if self.stats.active < self.number_tasks:
|
if self.stats.active < self.number_tasks:
|
||||||
task = self.sched.next()
|
task = next(self.sched)
|
||||||
if task is not None:
|
if task is not None:
|
||||||
fn = self.taskData.fn_index[self.runq_fnid[task]]
|
fn = self.taskData.fn_index[self.runq_fnid[task]]
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,7 @@ PROBLEMS:
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
from functools import reduce
|
||||||
try:
|
try:
|
||||||
set
|
set
|
||||||
except NameError:
|
except NameError:
|
||||||
|
@ -178,12 +179,12 @@ class BitBakeShellCommands:
|
||||||
print("ERROR: No Provider")
|
print("ERROR: No Provider")
|
||||||
last_exception = Providers.NoProvider
|
last_exception = Providers.NoProvider
|
||||||
|
|
||||||
except runqueue.TaskFailure, fnids:
|
except runqueue.TaskFailure as fnids:
|
||||||
for fnid in fnids:
|
for fnid in fnids:
|
||||||
print("ERROR: '%s' failed" % td.fn_index[fnid])
|
print("ERROR: '%s' failed" % td.fn_index[fnid])
|
||||||
last_exception = runqueue.TaskFailure
|
last_exception = runqueue.TaskFailure
|
||||||
|
|
||||||
except build.EventException, e:
|
except build.EventException as e:
|
||||||
print("ERROR: Couldn't build '%s'" % names)
|
print("ERROR: Couldn't build '%s'" % names)
|
||||||
last_exception = e
|
last_exception = e
|
||||||
|
|
||||||
|
@ -246,7 +247,7 @@ class BitBakeShellCommands:
|
||||||
cooker.buildFile(bf, cmd)
|
cooker.buildFile(bf, cmd)
|
||||||
except parse.ParseError:
|
except parse.ParseError:
|
||||||
print("ERROR: Unable to open or parse '%s'" % bf)
|
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)
|
print("ERROR: Couldn't build '%s'" % name)
|
||||||
last_exception = e
|
last_exception = e
|
||||||
|
|
||||||
|
@ -644,7 +645,7 @@ def columnize( alist, width = 80 ):
|
||||||
return reduce(lambda line, word, width=width: '%s%s%s' %
|
return reduce(lambda line, word, width=width: '%s%s%s' %
|
||||||
(line,
|
(line,
|
||||||
' \n'[(len(line[line.rfind('\n')+1:])
|
' \n'[(len(line[line.rfind('\n')+1:])
|
||||||
+ len(word.split('\n',1)[0]
|
+ len(word.split('\n', 1)[0]
|
||||||
) >= width)],
|
) >= width)],
|
||||||
word),
|
word),
|
||||||
alist
|
alist
|
||||||
|
|
|
@ -123,7 +123,7 @@ def init(server, eventHandler):
|
||||||
x = event.sofar
|
x = event.sofar
|
||||||
y = event.total
|
y = event.total
|
||||||
if os.isatty(sys.stdout.fileno()):
|
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()
|
sys.stdout.flush()
|
||||||
else:
|
else:
|
||||||
if x == 1:
|
if x == 1:
|
||||||
|
|
|
@ -266,7 +266,7 @@ class NCursesUI:
|
||||||
mw.appendText("Parsing finished. %d cached, %d parsed, %d skipped, %d masked."
|
mw.appendText("Parsing finished. %d cached, %d parsed, %d skipped, %d masked."
|
||||||
% ( event.cached, event.parsed, event.skipped, event.masked ))
|
% ( event.cached, event.parsed, event.skipped, event.masked ))
|
||||||
else:
|
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 isinstance(event, bb.build.TaskFailed):
|
||||||
# if event.logfile:
|
# if event.logfile:
|
||||||
# if data.getVar("BBINCLUDELOGS", d):
|
# if data.getVar("BBINCLUDELOGS", d):
|
||||||
|
|
|
@ -326,7 +326,7 @@ def better_exec(code, context, text, realfile):
|
||||||
"""
|
"""
|
||||||
import bb.parse
|
import bb.parse
|
||||||
try:
|
try:
|
||||||
exec code in _context, context
|
exec(code, _context, context)
|
||||||
except:
|
except:
|
||||||
(t, value, tb) = sys.exc_info()
|
(t, value, tb) = sys.exc_info()
|
||||||
|
|
||||||
|
@ -349,7 +349,7 @@ def better_exec(code, context, text, realfile):
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def simple_exec(code, context):
|
def simple_exec(code, context):
|
||||||
exec code in _context, context
|
exec(code, _context, context)
|
||||||
|
|
||||||
def better_eval(source, locals):
|
def better_eval(source, locals):
|
||||||
return eval(source, _context, locals)
|
return eval(source, _context, locals)
|
||||||
|
|
Loading…
Reference in New Issue