From 0c7272fb9a19e8cc44b8bfc262ea1d7d310f3521 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Wed, 14 Sep 2022 20:35:54 -0500 Subject: [PATCH 1/2] Output tweak --- parse_formats.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/parse_formats.py b/parse_formats.py index 8601b2a..fbad34b 100755 --- a/parse_formats.py +++ b/parse_formats.py @@ -3,6 +3,7 @@ import dataclasses import pathlib import re +import textwrap import typing as t cwd = pathlib.Path(__file__).parent @@ -72,8 +73,23 @@ def run() -> int: for manual in version_map.values(): print(f"tmux {manual.version}") - formats = ", ".join([format.variable_name for format in manual.formats]) - print(f" Formats: {formats}") + + # Array + formats = ", ".join([f'"{format.variable_name}"' for format in manual.formats]) + print(f" Formats: [{formats}]") + + # Dataclass + print( + textwrap.dedent( + f""" +@dataclasses.dataclass +class TmuxObject: + """ + + "\n ".join( + [f"{format.variable_name}: str" for format in manual.formats] + ) + ) + ) return 0 From 5c191d63e88e1f727ef2305ba1715af36bd3ba81 Mon Sep 17 00:00:00 2001 From: Tony Narlock Date: Sat, 17 Sep 2022 05:58:18 -0500 Subject: [PATCH 2/2] parse_formats: dataclasses output example, assertions --- parse_formats.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/parse_formats.py b/parse_formats.py index fbad34b..499a0fb 100755 --- a/parse_formats.py +++ b/parse_formats.py @@ -86,11 +86,28 @@ def run() -> int: class TmuxObject: """ + "\n ".join( - [f"{format.variable_name}: str" for format in manual.formats] + [ + f"{format.variable_name}: str | None = None" + for format in manual.formats + ] ) ) ) + raw_formats = [format.variable_name for format in manual.formats] + + if manual.version == "3.0a": + try: + assert "pane_title" in raw_formats + except AssertionError: + print("Should have pane title") + raise + elif manual.version == "3.3": + try: + assert "pane_title" not in raw_formats + except AssertionError: + print("Should not have pane_title") + return 0