From 54cb2f996402608f531c12ab1a7dfb4210c7c82d Mon Sep 17 00:00:00 2001 From: Gunnar Andersson Date: Mon, 14 Aug 2023 18:59:56 +0200 Subject: [PATCH] Add ifexgen_dbus command and required dependencies l. ifexgen_dbus is a frontend / executable command, defined in the package information (setup.py) and which calls the actual code. I just followed the same pattern as for ifexgen. 2. Rename D-Bus (correct spelling) to DBus (wrong spelling) because...python reasons :( Signed-off-by: Gunnar Andersson --- ifex/generators/{D-Bus => DBus}/__init__.py | 0 .../{D-Bus => DBus}/dbus_generator.py | 0 ifex/generators/{D-Bus => DBus}/dbus_types.py | 0 ifex/scripts/generator_dbus.py | 23 +++++++++++++++++++ requirements.txt | 1 + setup.py | 1 + 6 files changed, 25 insertions(+) rename ifex/generators/{D-Bus => DBus}/__init__.py (100%) rename ifex/generators/{D-Bus => DBus}/dbus_generator.py (100%) rename ifex/generators/{D-Bus => DBus}/dbus_types.py (100%) create mode 100644 ifex/scripts/generator_dbus.py diff --git a/ifex/generators/D-Bus/__init__.py b/ifex/generators/DBus/__init__.py similarity index 100% rename from ifex/generators/D-Bus/__init__.py rename to ifex/generators/DBus/__init__.py diff --git a/ifex/generators/D-Bus/dbus_generator.py b/ifex/generators/DBus/dbus_generator.py similarity index 100% rename from ifex/generators/D-Bus/dbus_generator.py rename to ifex/generators/DBus/dbus_generator.py diff --git a/ifex/generators/D-Bus/dbus_types.py b/ifex/generators/DBus/dbus_types.py similarity index 100% rename from ifex/generators/D-Bus/dbus_types.py rename to ifex/generators/DBus/dbus_types.py diff --git a/ifex/scripts/generator_dbus.py b/ifex/scripts/generator_dbus.py new file mode 100644 index 0000000..a7f8b50 --- /dev/null +++ b/ifex/scripts/generator_dbus.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: Copyright (c) 2023 MBition GmbH. +# SPDX-License-Identifier: MPL-2.0 + +# User-invocation script for D-Bus generation +# (small wrapper around the main implementation) + +from ifex.model.ifex_parser import get_ast_from_yaml_file +from ifex.generators.DBus import dbus_generator +import argparse, dacite + +def ifex_dbus_generator_run(): + parser = argparse.ArgumentParser(description='Runs IFEX to D-Bus XML translator.') + parser.add_argument('input', metavar='ifex-input-file', type=str, help='path to input IFEX (YAML) file') + + try: + args = parser.parse_args() + dbus_generator.main_generate(args.input) + + except dacite.UnexpectedDataError as e: + print(f"ERROR: Read error resulting from {filename}: {e}") + +if __name__ == "__main__": + ifex_dbus_generator_run() diff --git a/requirements.txt b/requirements.txt index 1777382..87a1c73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ attrs==22.1.0 iniconfig==1.1.1 Jinja2==3.1.2 +lxml MarkupSafe==2.1.1 packaging==21.3 pluggy==1.0.0 diff --git a/setup.py b/setup.py index 7a75de8..c41a43c 100644 --- a/setup.py +++ b/setup.py @@ -26,5 +26,6 @@ def get_template_files(): entry_points=''' [console_scripts] ifexgen=ifex.scripts.generator:ifex_generator_run + ifexgen_dbus=ifex.scripts.generator_dbus:ifex_dbus_generator_run ''' )