[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 02/11] scripts: qapi: black format main.py
From: |
Victor Toso |
Subject: |
[PATCH v2 02/11] scripts: qapi: black format main.py |
Date: |
Mon, 16 Oct 2023 17:26:55 +0200 |
flake8 complained:
./main.py:60:1: E302 expected 2 blank lines, found 1
Which is simple enough. My vim has black [0] enabled by default, so it
did some extra formatting. I'm proposing to follow it.
[0] https://black.readthedocs.io/en/stable/
Signed-off-by: Victor Toso <victortoso@redhat.com>
---
scripts/qapi/main.py | 76 ++++++++++++++++++++++++++++----------------
1 file changed, 48 insertions(+), 28 deletions(-)
diff --git a/scripts/qapi/main.py b/scripts/qapi/main.py
index 316736b6a2..fe65c1a17a 100644
--- a/scripts/qapi/main.py
+++ b/scripts/qapi/main.py
@@ -22,18 +22,20 @@
def invalid_prefix_char(prefix: str) -> Optional[str]:
- match = must_match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', prefix)
+ match = must_match(r"([A-Za-z_.-][A-Za-z0-9_.-]*)?", prefix)
if match.end() != len(prefix):
return prefix[match.end()]
return None
-def generate(schema_file: str,
- output_dir: str,
- prefix: str,
- unmask: bool = False,
- builtins: bool = False,
- gen_tracing: bool = False) -> None:
+def generate(
+ schema_file: str,
+ output_dir: str,
+ prefix: str,
+ unmask: bool = False,
+ builtins: bool = False,
+ gen_tracing: bool = False,
+) -> None:
"""
Generate C code for the given schema into the target directory.
@@ -63,25 +65,41 @@ def main() -> int:
:return: int, 0 on success, 1 on failure.
"""
parser = argparse.ArgumentParser(
- description='Generate code from a QAPI schema')
- parser.add_argument('-b', '--builtins', action='store_true',
- help="generate code for built-in types")
- parser.add_argument('-o', '--output-dir', action='store',
- default='',
- help="write output to directory OUTPUT_DIR")
- parser.add_argument('-p', '--prefix', action='store',
- default='',
- help="prefix for symbols")
- parser.add_argument('-u', '--unmask-non-abi-names', action='store_true',
- dest='unmask',
- help="expose non-ABI names in introspection")
+ description="Generate code from a QAPI schema"
+ )
+ parser.add_argument(
+ "-b",
+ "--builtins",
+ action="store_true",
+ help="generate code for built-in types",
+ )
+ parser.add_argument(
+ "-o",
+ "--output-dir",
+ action="store",
+ default="",
+ help="write output to directory OUTPUT_DIR",
+ )
+ parser.add_argument(
+ "-p", "--prefix", action="store", default="", help="prefix for symbols"
+ )
+ parser.add_argument(
+ "-u",
+ "--unmask-non-abi-names",
+ action="store_true",
+ dest="unmask",
+ help="expose non-ABI names in introspection",
+ )
# Option --suppress-tracing exists so we can avoid solving build system
# problems. TODO Drop it when we no longer need it.
- parser.add_argument('--suppress-tracing', action='store_true',
- help="suppress adding trace events to qmp marshals")
+ parser.add_argument(
+ "--suppress-tracing",
+ action="store_true",
+ help="suppress adding trace events to qmp marshals",
+ )
- parser.add_argument('schema', action='store')
+ parser.add_argument("schema", action="store")
args = parser.parse_args()
funny_char = invalid_prefix_char(args.prefix)
@@ -91,12 +109,14 @@ def main() -> int:
return 1
try:
- generate(args.schema,
- output_dir=args.output_dir,
- prefix=args.prefix,
- unmask=args.unmask,
- builtins=args.builtins,
- gen_tracing=not args.suppress_tracing)
+ generate(
+ args.schema,
+ output_dir=args.output_dir,
+ prefix=args.prefix,
+ unmask=args.unmask,
+ builtins=args.builtins,
+ gen_tracing=not args.suppress_tracing,
+ )
except QAPIError as err:
print(err, file=sys.stderr)
return 1
--
2.41.0
[PATCH v2 08/11] qapi: golang: Generate qapi's event types in Go, Victor Toso, 2023/10/16
[PATCH v2 07/11] qapi: golang: Generate qapi's union types in Go, Victor Toso, 2023/10/16
[PATCH v2 09/11] qapi: golang: Generate qapi's command types in Go, Victor Toso, 2023/10/16
[PATCH v2 10/11] qapi: golang: Add CommandResult type to Go, Victor Toso, 2023/10/16
[PATCH v2 11/11] docs: add notes on Golang code generator, Victor Toso, 2023/10/16