mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-06-05 22:31:36 +00:00
dtoc: Adjust code for Python 3
Update a few things in this tool so that they support Python 3: - print statements - iteritems() - xrange() Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
b2e73125b2
commit
90a8132f4d
4 changed files with 15 additions and 9 deletions
|
@ -449,7 +449,7 @@ class DtbPlatdata(object):
|
||||||
self.out(';\n')
|
self.out(';\n')
|
||||||
self.out('};\n')
|
self.out('};\n')
|
||||||
|
|
||||||
for alias, struct_name in self._aliases.iteritems():
|
for alias, struct_name in self._aliases.items():
|
||||||
if alias not in sorted(structs):
|
if alias not in sorted(structs):
|
||||||
self.out('#define %s%s %s%s\n'% (STRUCT_PREFIX, alias,
|
self.out('#define %s%s %s%s\n'% (STRUCT_PREFIX, alias,
|
||||||
STRUCT_PREFIX, struct_name))
|
STRUCT_PREFIX, struct_name))
|
||||||
|
@ -498,7 +498,7 @@ class DtbPlatdata(object):
|
||||||
vals.append(get_value(prop.type, val))
|
vals.append(get_value(prop.type, val))
|
||||||
|
|
||||||
# Put 8 values per line to avoid very long lines.
|
# Put 8 values per line to avoid very long lines.
|
||||||
for i in xrange(0, len(vals), 8):
|
for i in range(0, len(vals), 8):
|
||||||
if i:
|
if i:
|
||||||
self.buf(',\n\t\t')
|
self.buf(',\n\t\t')
|
||||||
self.buf(', '.join(vals[i:i + 8]))
|
self.buf(', '.join(vals[i:i + 8]))
|
||||||
|
|
|
@ -25,6 +25,8 @@ options. For more information about the use of this options and tool please
|
||||||
see doc/driver-model/of-plat.txt
|
see doc/driver-model/of-plat.txt
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -64,11 +66,11 @@ def run_tests(args):
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(module)
|
suite = unittest.TestLoader().loadTestsFromTestCase(module)
|
||||||
suite.run(result)
|
suite.run(result)
|
||||||
|
|
||||||
print result
|
print(result)
|
||||||
for _, err in result.errors:
|
for _, err in result.errors:
|
||||||
print err
|
print(err)
|
||||||
for _, err in result.failures:
|
for _, err in result.failures:
|
||||||
print err
|
print(err)
|
||||||
|
|
||||||
def RunTestCoverage():
|
def RunTestCoverage():
|
||||||
"""Run the tests and check that we get 100% coverage"""
|
"""Run the tests and check that we get 100% coverage"""
|
||||||
|
|
|
@ -8,6 +8,8 @@ This includes unit tests for some functions and functional tests for the dtoc
|
||||||
tool.
|
tool.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
import os
|
import os
|
||||||
import struct
|
import struct
|
||||||
|
@ -97,7 +99,7 @@ class TestDtoc(unittest.TestCase):
|
||||||
if expected != actual:
|
if expected != actual:
|
||||||
self._WritePythonString('/tmp/binman.expected', expected)
|
self._WritePythonString('/tmp/binman.expected', expected)
|
||||||
self._WritePythonString('/tmp/binman.actual', actual)
|
self._WritePythonString('/tmp/binman.actual', actual)
|
||||||
print 'Failures written to /tmp/binman.{expected,actual}'
|
print('Failures written to /tmp/binman.{expected,actual}')
|
||||||
self.assertEquals(expected, actual)
|
self.assertEquals(expected, actual)
|
||||||
|
|
||||||
def test_name(self):
|
def test_name(self):
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
# Written by Simon Glass <sjg@chromium.org>
|
# Written by Simon Glass <sjg@chromium.org>
|
||||||
#
|
#
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
@ -535,11 +537,11 @@ def RunTests(args):
|
||||||
suite = unittest.TestLoader().loadTestsFromTestCase(module)
|
suite = unittest.TestLoader().loadTestsFromTestCase(module)
|
||||||
suite.run(result)
|
suite.run(result)
|
||||||
|
|
||||||
print result
|
print(result)
|
||||||
for _, err in result.errors:
|
for _, err in result.errors:
|
||||||
print err
|
print(err)
|
||||||
for _, err in result.failures:
|
for _, err in result.failures:
|
||||||
print err
|
print(err)
|
||||||
|
|
||||||
if __name__ != '__main__':
|
if __name__ != '__main__':
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue