summaryrefslogtreecommitdiff
path: root/extra/usb_power/convert_power_log_board.py
diff options
context:
space:
mode:
Diffstat (limited to 'extra/usb_power/convert_power_log_board.py')
-rw-r--r--extra/usb_power/convert_power_log_board.py47
1 files changed, 27 insertions, 20 deletions
diff --git a/extra/usb_power/convert_power_log_board.py b/extra/usb_power/convert_power_log_board.py
index 8aab77ee4c..f5fb7e925d 100644
--- a/extra/usb_power/convert_power_log_board.py
+++ b/extra/usb_power/convert_power_log_board.py
@@ -1,11 +1,7 @@
#!/usr/bin/env python
-# Copyright 2018 The Chromium OS Authors. All rights reserved.
+# Copyright 2018 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
-#
-# Ignore indention messages, since legacy scripts use 2 spaces instead of 4.
-# pylint: disable=bad-indentation,docstring-section-indent
-# pylint: disable=docstring-trailing-quotes
"""
Program to convert sweetberry config to servod config template.
@@ -14,11 +10,12 @@ Program to convert sweetberry config to servod config template.
# Note: This is a py2/3 compatible file.
from __future__ import print_function
+
import json
import os
import sys
-from powerlog import Spower
+from powerlog import Spower # pylint:disable=import-error
def fetch_records(board_file):
@@ -48,21 +45,29 @@ def write_to_file(file, sweetberry, inas):
inas: list of inas read from board file.
"""
- with open(file, 'w') as pyfile:
+ with open(file, "w") as pyfile:
- pyfile.write('inas = [\n')
+ pyfile.write("inas = [\n")
for rec in inas:
- if rec['sweetberry'] != sweetberry:
+ if rec["sweetberry"] != sweetberry:
continue
# EX : ('sweetberry', 0x40, 'SB_FW_CAM_2P8', 5.0, 1.000, 3, False),
- channel, i2c_addr = Spower.CHMAP[rec['channel']]
- record = (" ('sweetberry', 0x%02x, '%s', 5.0, %f, %d, 'True')"
- ",\n" % (i2c_addr, rec['name'], rec['rs'], channel))
+ channel, i2c_addr = Spower.CHMAP[rec["channel"]]
+ record = (
+ " ('sweetberry', 0x%02x, '%s', 5.0, %f, %d, 'True')"
+ ",\n"
+ % (
+ i2c_addr,
+ rec["name"],
+ rec["rs"],
+ channel,
+ )
+ )
pyfile.write(record)
- pyfile.write(']\n')
+ pyfile.write("]\n")
def main(argv):
@@ -76,16 +81,18 @@ def main(argv):
inas = fetch_records(inputf)
- sweetberry = set(rec['sweetberry'] for rec in inas)
+ sweetberry = set(rec["sweetberry"] for rec in inas)
if len(sweetberry) == 2:
- print("Converting %s to %s and %s" % (inputf, basename + '_a.py',
- basename + '_b.py'))
- write_to_file(basename + '_a.py', 'A', inas)
- write_to_file(basename + '_b.py', 'B', inas)
+ print(
+ "Converting %s to %s and %s"
+ % (inputf, basename + "_a.py", basename + "_b.py")
+ )
+ write_to_file(basename + "_a.py", "A", inas)
+ write_to_file(basename + "_b.py", "B", inas)
else:
- print("Converting %s to %s" % (inputf, basename + '.py'))
- write_to_file(basename + '.py', sweetberry.pop(), inas)
+ print("Converting %s to %s" % (inputf, basename + ".py"))
+ write_to_file(basename + ".py", sweetberry.pop(), inas)
if __name__ == "__main__":