mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-18 21:21:37 +00:00
genboardscfg.py: Convert to Python 3
Convert this tool to requiring Python 3. The bulk of this is done with the 2to3 tool In addition, we need to use the '//' operator to have our division result return an int rather than a float and ensure that we use UTF-8 when reading/writing files. Cc: Masahiro Yamada <yamada.masahiro@socionext.com> Signed-off-by: Tom Rini <trini@konsulko.com>
This commit is contained in:
parent
61ba1244b5
commit
3bc14098d8
1 changed files with 13 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
# SPDX-License-Identifier: GPL-2.0+
|
# SPDX-License-Identifier: GPL-2.0+
|
||||||
#
|
#
|
||||||
# Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
|
# Author: Masahiro Yamada <yamada.m@jp.panasonic.com>
|
||||||
|
@ -91,7 +91,7 @@ def output_is_new(output):
|
||||||
|
|
||||||
# Detect a board that has been removed since the current board database
|
# Detect a board that has been removed since the current board database
|
||||||
# was generated
|
# was generated
|
||||||
with open(output) as f:
|
with open(output, encoding="utf-8") as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
if line[0] == '#' or line == '\n':
|
if line[0] == '#' or line == '\n':
|
||||||
continue
|
continue
|
||||||
|
@ -168,7 +168,7 @@ class KconfigScanner:
|
||||||
warnings = self._conf.load_config(self._tmpfile)
|
warnings = self._conf.load_config(self._tmpfile)
|
||||||
if warnings:
|
if warnings:
|
||||||
for warning in warnings:
|
for warning in warnings:
|
||||||
print '%s: %s' % (defconfig, warning)
|
print('%s: %s' % (defconfig, warning))
|
||||||
|
|
||||||
try_remove(self._tmpfile)
|
try_remove(self._tmpfile)
|
||||||
self._tmpfile = None
|
self._tmpfile = None
|
||||||
|
@ -177,7 +177,7 @@ class KconfigScanner:
|
||||||
|
|
||||||
# Get the value of CONFIG_SYS_ARCH, CONFIG_SYS_CPU, ... etc.
|
# Get the value of CONFIG_SYS_ARCH, CONFIG_SYS_CPU, ... etc.
|
||||||
# Set '-' if the value is empty.
|
# Set '-' if the value is empty.
|
||||||
for key, symbol in self._SYMBOL_TABLE.items():
|
for key, symbol in list(self._SYMBOL_TABLE.items()):
|
||||||
value = self._conf.get_symbol(symbol).get_value()
|
value = self._conf.get_symbol(symbol).get_value()
|
||||||
if value:
|
if value:
|
||||||
params[key] = value
|
params[key] = value
|
||||||
|
@ -242,8 +242,8 @@ def scan_defconfigs(jobs=1):
|
||||||
processes = []
|
processes = []
|
||||||
queues = []
|
queues = []
|
||||||
for i in range(jobs):
|
for i in range(jobs):
|
||||||
defconfigs = all_defconfigs[total_boards * i / jobs :
|
defconfigs = all_defconfigs[total_boards * i // jobs :
|
||||||
total_boards * (i + 1) / jobs]
|
total_boards * (i + 1) // jobs]
|
||||||
q = multiprocessing.Queue(maxsize=-1)
|
q = multiprocessing.Queue(maxsize=-1)
|
||||||
p = multiprocessing.Process(target=scan_defconfigs_for_multiprocess,
|
p = multiprocessing.Process(target=scan_defconfigs_for_multiprocess,
|
||||||
args=(q, defconfigs))
|
args=(q, defconfigs))
|
||||||
|
@ -290,7 +290,7 @@ class MaintainersDatabase:
|
||||||
'Active', 'Orphan' or '-'.
|
'Active', 'Orphan' or '-'.
|
||||||
"""
|
"""
|
||||||
if not target in self.database:
|
if not target in self.database:
|
||||||
print >> sys.stderr, "WARNING: no status info for '%s'" % target
|
print("WARNING: no status info for '%s'" % target, file=sys.stderr)
|
||||||
return '-'
|
return '-'
|
||||||
|
|
||||||
tmp = self.database[target][0]
|
tmp = self.database[target][0]
|
||||||
|
@ -301,8 +301,8 @@ class MaintainersDatabase:
|
||||||
elif tmp.startswith('Orphan'):
|
elif tmp.startswith('Orphan'):
|
||||||
return 'Orphan'
|
return 'Orphan'
|
||||||
else:
|
else:
|
||||||
print >> sys.stderr, ("WARNING: %s: unknown status for '%s'" %
|
print(("WARNING: %s: unknown status for '%s'" %
|
||||||
(tmp, target))
|
(tmp, target)), file=sys.stderr)
|
||||||
return '-'
|
return '-'
|
||||||
|
|
||||||
def get_maintainers(self, target):
|
def get_maintainers(self, target):
|
||||||
|
@ -313,7 +313,7 @@ class MaintainersDatabase:
|
||||||
they are separated with colons.
|
they are separated with colons.
|
||||||
"""
|
"""
|
||||||
if not target in self.database:
|
if not target in self.database:
|
||||||
print >> sys.stderr, "WARNING: no maintainers for '%s'" % target
|
print("WARNING: no maintainers for '%s'" % target, file=sys.stderr)
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
return ':'.join(self.database[target][1])
|
return ':'.join(self.database[target][1])
|
||||||
|
@ -330,7 +330,7 @@ class MaintainersDatabase:
|
||||||
targets = []
|
targets = []
|
||||||
maintainers = []
|
maintainers = []
|
||||||
status = '-'
|
status = '-'
|
||||||
for line in open(file):
|
for line in open(file, encoding="utf-8"):
|
||||||
# Check also commented maintainers
|
# Check also commented maintainers
|
||||||
if line[:3] == '#M:':
|
if line[:3] == '#M:':
|
||||||
line = line[1:]
|
line = line[1:]
|
||||||
|
@ -404,7 +404,7 @@ def format_and_output(params_list, output):
|
||||||
# ignore case when sorting
|
# ignore case when sorting
|
||||||
output_lines.sort(key=str.lower)
|
output_lines.sort(key=str.lower)
|
||||||
|
|
||||||
with open(output, 'w') as f:
|
with open(output, 'w', encoding="utf-8") as f:
|
||||||
f.write(COMMENT_BLOCK + '\n'.join(output_lines) + '\n')
|
f.write(COMMENT_BLOCK + '\n'.join(output_lines) + '\n')
|
||||||
|
|
||||||
def gen_boards_cfg(output, jobs=1, force=False):
|
def gen_boards_cfg(output, jobs=1, force=False):
|
||||||
|
@ -418,7 +418,7 @@ def gen_boards_cfg(output, jobs=1, force=False):
|
||||||
check_top_directory()
|
check_top_directory()
|
||||||
|
|
||||||
if not force and output_is_new(output):
|
if not force and output_is_new(output):
|
||||||
print "%s is up to date. Nothing to do." % output
|
print("%s is up to date. Nothing to do." % output)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
params_list = scan_defconfigs(jobs)
|
params_list = scan_defconfigs(jobs)
|
||||||
|
|
Loading…
Add table
Reference in a new issue