python: fix flake8 warnings and format with black
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I90fe7f4eccb9014245225b6bc61183d7455b0fae
diff --git a/power-sequencer/gen-ucd90160-defs.py b/power-sequencer/gen-ucd90160-defs.py
index b191ef6..66bbb9b 100755
--- a/power-sequencer/gen-ucd90160-defs.py
+++ b/power-sequencer/gen-ucd90160-defs.py
@@ -1,22 +1,32 @@
#!/usr/bin/env python3
import os
-import yaml
+import sys
from argparse import ArgumentParser
-from mako.template import Template
+
+import yaml
from mako.lookup import TemplateLookup
-if __name__ == '__main__':
+if __name__ == "__main__":
parser = ArgumentParser(
- description="Power sequencer UCD90160 definition parser")
+ description="Power sequencer UCD90160 definition parser"
+ )
- parser.add_argument('-i', '--input_yaml', dest='input_yaml',
- default="example/ucd90160.yaml",
- help='UCD90160 definitions YAML')
+ parser.add_argument(
+ "-i",
+ "--input_yaml",
+ dest="input_yaml",
+ default="example/ucd90160.yaml",
+ help="UCD90160 definitions YAML",
+ )
- parser.add_argument('-o', '--output_dir', dest='output_dir',
- default=".",
- help='output directory')
+ parser.add_argument(
+ "-o",
+ "--output_dir",
+ dest="output_dir",
+ default=".",
+ help="output directory",
+ )
args = parser.parse_args()
@@ -24,18 +34,17 @@
parser.print_usage()
sys.exit(1)
- with open(args.input_yaml, 'r') as ucd90160_input:
+ with open(args.input_yaml, "r") as ucd90160_input:
ucd90160_data = yaml.safe_load(ucd90160_input) or {}
templates_dir = os.path.join(
- os.path.dirname(os.path.realpath(__file__)),
- "templates")
+ os.path.dirname(os.path.realpath(__file__)), "templates"
+ )
output_file = os.path.join(args.output_dir, "ucd90160_defs.cpp")
- mylookup = TemplateLookup(
- directories=templates_dir.split())
- mytemplate = mylookup.get_template('ucd90160_defs.mako.cpp')
+ mylookup = TemplateLookup(directories=templates_dir.split())
+ mytemplate = mylookup.get_template("ucd90160_defs.mako.cpp")
- with open(output_file, 'w') as output:
+ with open(output_file, "w") as output:
output.write(mytemplate.render(ucd90160s=ucd90160_data))