black: re-format
black and isort are enabled in the openbmc-build-scripts on Python files
to have a consistent formatting. Re-run the formatter on the whole
repository.
Change-Id: I6c39862420de0e038e69e2409f9f9e70cac4e6b9
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/scripts/inventory-sensor.py b/scripts/inventory-sensor.py
index 1a4e5db..be5cae6 100755
--- a/scripts/inventory-sensor.py
+++ b/scripts/inventory-sensor.py
@@ -1,60 +1,69 @@
#!/usr/bin/env python3
+import argparse
import os
import sys
+
import yaml
-import argparse
from mako.template import Template
def generate_cpp(sensor_yaml, output_dir):
- with open(sensor_yaml, 'r') as f:
+ with open(sensor_yaml, "r") as f:
ifile = yaml.safe_load(f)
if not isinstance(ifile, dict):
ifile = {}
# Render the mako template
- t = Template(filename=os.path.join(
- script_dir,
- "inventorysensor.mako.cpp"))
+ t = Template(
+ filename=os.path.join(script_dir, "inventorysensor.mako.cpp")
+ )
output_cpp = os.path.join(output_dir, "inventory-sensor-gen.cpp")
- with open(output_cpp, 'w') as fd:
+ with open(output_cpp, "w") as fd:
fd.write(t.render(sensorDict=ifile))
def main():
-
- valid_commands = {
- 'generate-cpp': generate_cpp
- }
+ valid_commands = {"generate-cpp": generate_cpp}
parser = argparse.ArgumentParser(
- description="Inventory Object to IPMI SensorID code generator")
+ description="Inventory Object to IPMI SensorID code generator"
+ )
parser.add_argument(
- '-i', '--sensor_yaml', dest='sensor_yaml',
- default='example.yaml', help='input sensor yaml file to parse')
+ "-i",
+ "--sensor_yaml",
+ dest="sensor_yaml",
+ default="example.yaml",
+ help="input sensor yaml file to parse",
+ )
parser.add_argument(
- "-o", "--output-dir", dest="outputdir",
+ "-o",
+ "--output-dir",
+ dest="outputdir",
default=".",
- help="output directory")
+ help="output directory",
+ )
parser.add_argument(
- 'command', metavar='COMMAND', type=str,
+ "command",
+ metavar="COMMAND",
+ type=str,
choices=valid_commands.keys(),
- help='Command to run.')
+ help="Command to run.",
+ )
args = parser.parse_args()
- if (not (os.path.isfile(args.sensor_yaml))):
+ if not (os.path.isfile(args.sensor_yaml)):
sys.exit("Can not find input yaml file " + args.sensor_yaml)
function = valid_commands[args.command]
function(args.sensor_yaml, args.outputdir)
-if __name__ == '__main__':
+if __name__ == "__main__":
script_dir = os.path.dirname(os.path.realpath(__file__))
main()