Reported by pylint's 'bad-whitespace' warning. Not gonna enable this warning in the CI check, because it flags stuff like deliberately aligning assignments and gets too cultish. Just a cleanup pass. For whatever reason, the common convention in Python is to skip spaces around '=' when passing keyword arguments and giving default arguments: f(x=3, y=4) def f(x, y=8): ... Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
37 lines
872 B
Python
Executable file
37 lines
872 B
Python
Executable file
#!/usr/bin/env python
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
import ConfigParser, os
|
|
import yaml
|
|
import sys
|
|
|
|
|
|
sample = False
|
|
in_file = sys.argv[1]
|
|
if sys.argv[2] == 'sample':
|
|
sample = True
|
|
|
|
out_file = os.path.join(os.path.dirname(in_file), sys.argv[2] + ".yaml")
|
|
|
|
config = ConfigParser.ConfigParser()
|
|
config.readfp(open(sys.argv[1]))
|
|
y = {'tests': 'tests'}
|
|
|
|
tests = []
|
|
for section in config.sections():
|
|
tc = {}
|
|
for opt in config.options(section):
|
|
value = config.get(section, opt)
|
|
if value in ['false', 'true']:
|
|
tc[opt] = True if value == 'true' else False
|
|
else:
|
|
tc[opt] = value
|
|
|
|
test = {section : tc}
|
|
tests.append(test)
|
|
|
|
y['tests'] = tests
|
|
if sample:
|
|
y['sample'] = {'name': "TBD", 'description': "TBD"}
|
|
|
|
with open(out_file, "w") as f:
|
|
yaml.dump(y, f, width=50, indent=4, default_flow_style=False)
|