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: I5e068068ef3faa2f2c77bc1726b134eb6268dcfb
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
diff --git a/scripts/extra-properties.py b/scripts/extra-properties.py
index c63ec9c..115abf7 100755
--- a/scripts/extra-properties.py
+++ b/scripts/extra-properties.py
@@ -1,34 +1,36 @@
#!/usr/bin/env python3
+import argparse
import os
+
import yaml
from mako.template import Template
-import argparse
def main():
parser = argparse.ArgumentParser(
- description="IPMI FRU VPD parser and code generator")
+ description="IPMI FRU VPD parser and code generator"
+ )
parser.add_argument(
- '-e', '--extra_props_yaml',
- dest='extra_props_yaml',
- default='extra-properties-example.yaml',
- help='input extra properties yaml file to parse')
+ "-e",
+ "--extra_props_yaml",
+ dest="extra_props_yaml",
+ default="extra-properties-example.yaml",
+ help="input extra properties yaml file to parse",
+ )
args = parser.parse_args()
- with open(os.path.join(script_dir, args.extra_props_yaml), 'r') as fd:
+ with open(os.path.join(script_dir, args.extra_props_yaml), "r") as fd:
yamlDict = yaml.safe_load(fd)
# Render the mako template
- template = os.path.join(script_dir, 'extra-properties.mako.cpp')
+ template = os.path.join(script_dir, "extra-properties.mako.cpp")
t = Template(filename=template)
- with open('extra-properties-gen.cpp', 'w') as fd:
- fd.write(
- t.render(
- dict=yamlDict))
+ with open("extra-properties-gen.cpp", "w") as fd:
+ fd.write(t.render(dict=yamlDict))
-if __name__ == '__main__':
+if __name__ == "__main__":
script_dir = os.path.dirname(os.path.realpath(__file__))
main()
diff --git a/scripts/fru_gen.py b/scripts/fru_gen.py
index 5241f2f..624d052 100755
--- a/scripts/fru_gen.py
+++ b/scripts/fru_gen.py
@@ -1,59 +1,67 @@
#!/usr/bin/env python3
+import argparse
import os
import sys
+
import yaml
-import argparse
from mako.template import Template
def generate_cpp(inventory_yaml, output_dir):
- with open(os.path.join(script_dir, inventory_yaml), 'r') as f:
+ with open(os.path.join(script_dir, inventory_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,
- "writefru.mako.cpp"))
+ t = Template(filename=os.path.join(script_dir, "writefru.mako.cpp"))
output_hpp = os.path.join(output_dir, "fru-gen.cpp")
- with open(output_hpp, 'w') as fd:
+ with open(output_hpp, "w") as fd:
fd.write(t.render(fruDict=ifile))
def main():
-
- valid_commands = {
- 'generate-cpp': generate_cpp
- }
+ valid_commands = {"generate-cpp": generate_cpp}
parser = argparse.ArgumentParser(
- description="IPMI FRU parser and code generator")
+ description="IPMI FRU parser and code generator"
+ )
parser.add_argument(
- '-i', '--inventory_yaml', dest='inventory_yaml',
- default='example.yaml', help='input inventory yaml file to parse')
+ "-i",
+ "--inventory_yaml",
+ dest="inventory_yaml",
+ default="example.yaml",
+ help="input inventory 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=list(valid_commands.keys()),
- help='Command to run.')
+ help="Command to run.",
+ )
args = parser.parse_args()
- if (not (os.path.isfile(os.path.join(script_dir, args.inventory_yaml)))):
+ if not (os.path.isfile(os.path.join(script_dir, args.inventory_yaml))):
sys.exit("Can not find input yaml file " + args.inventory_yaml)
function = valid_commands[args.command]
function(args.inventory_yaml, args.outputdir)
-if __name__ == '__main__':
+
+if __name__ == "__main__":
script_dir = os.path.dirname(os.path.realpath(__file__))
main()
diff --git a/scripts/gen_pimrules.py b/scripts/gen_pimrules.py
index 7a0e479..5b82cdc 100755
--- a/scripts/gen_pimrules.py
+++ b/scripts/gen_pimrules.py
@@ -1,15 +1,16 @@
#!/usr/bin/env python3
-'''Generate PIM rules for ipmi-fru-parser.
-'''
+"""Generate PIM rules for ipmi-fru-parser.
+"""
import argparse
import os
import sys
+
import yaml
from mako.template import Template
-tmpl = '''
+tmpl = """
description: >
PIM rules for ipmi-fru-parser inventory objects.
events:
@@ -117,7 +118,7 @@
value:
type: ${cacheable_type}
value: ${cacheable_cached}
-'''
+"""
def get_cacheable_objs(yaml):
@@ -136,48 +137,58 @@
return cacheable
-if __name__ == '__main__':
+if __name__ == "__main__":
script_dir = os.path.dirname(os.path.realpath(__file__))
parser = argparse.ArgumentParser(
- description='ipmi-fru-parser PIM rule generator.')
+ description="ipmi-fru-parser PIM rule generator."
+ )
parser.add_argument(
- '-o', '--output-dir', dest='outputdir',
- default='.', help='Output directory.')
+ "-o",
+ "--output-dir",
+ dest="outputdir",
+ default=".",
+ help="Output directory.",
+ )
parser.add_argument(
- 'inventory', metavar='INVENTORY', type=str,
- help='Path to inventory YAML.')
+ "inventory",
+ metavar="INVENTORY",
+ type=str,
+ help="Path to inventory YAML.",
+ )
args = parser.parse_args()
- with open(args.inventory, 'r') as fd:
+ with open(args.inventory, "r") as fd:
data = yaml.safe_load(fd.read())
- cacheable_iface_name = 'xyz.openbmc_project.Inventory.Decorator.Cacheable'
- target_file = os.path.join(args.outputdir, 'ipmi-fru-rules.yaml')
+ cacheable_iface_name = "xyz.openbmc_project.Inventory.Decorator.Cacheable"
+ target_file = os.path.join(args.outputdir, "ipmi-fru-rules.yaml")
cacheable = []
if isinstance(data, dict):
cacheable = get_cacheable_objs(data)
if cacheable:
- with open(target_file, 'w') as out:
+ with open(target_file, "w") as out:
out.write(
Template(tmpl).render(
cacheable_iface=cacheable_iface_name,
- cacheable_property='Cached',
- cacheable_cached='true',
- cacheable_type='boolean',
- on_path='/xyz/openbmc_project/state/host0',
- on_iface='xyz.openbmc_project.State.Boot.Progress',
- on_property='BootProgress',
- on_value='xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart',
- on_type='string',
- off_path='/xyz/openbmc_project/state/host0',
- off_iface='xyz.openbmc_project.State.Host',
- off_property='CurrentHostState',
- off_value='xyz.openbmc_project.State.Host.Off',
- off_type='string',
- cacheable=cacheable))
+ cacheable_property="Cached",
+ cacheable_cached="true",
+ cacheable_type="boolean",
+ on_path="/xyz/openbmc_project/state/host0",
+ on_iface="xyz.openbmc_project.State.Boot.Progress",
+ on_property="BootProgress",
+ on_value="xyz.openbmc_project.State.Boot.Progress.ProgressStages.OSStart",
+ on_type="string",
+ off_path="/xyz/openbmc_project/state/host0",
+ off_iface="xyz.openbmc_project.State.Host",
+ off_property="CurrentHostState",
+ off_value="xyz.openbmc_project.State.Host.Off",
+ off_type="string",
+ cacheable=cacheable,
+ )
+ )
# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4