From 371003a09d7b0e81fe7e207c7d0e99438e4969d9 Mon Sep 17 00:00:00 2001 From: Camille <78221213+clatapie@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:42:36 +0100 Subject: [PATCH] fix: removing extra argument instead of extra coma --- src/pyconverter/xml2py/ast_tree.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/pyconverter/xml2py/ast_tree.py b/src/pyconverter/xml2py/ast_tree.py index fee95c948..e0201d910 100644 --- a/src/pyconverter/xml2py/ast_tree.py +++ b/src/pyconverter/xml2py/ast_tree.py @@ -2435,6 +2435,9 @@ def py_arg_names(self): @property def additional_args(self): return self._additional_args + + def remove_last_arg(self): + self._arguments.pop() class XMLCommand(Element): @@ -2513,6 +2516,10 @@ def arg_desc(self) -> List[Argument]: arg_file = Path("args.txt") if arguments is not None: + # Remove last argument if it's empty + while arguments.py_arg_names[-1] == "": + arguments.remove_last_arg() + if len(arguments.py_arg_names) != len(arguments.initial_args): # This function needs a special treatment if arg_file.exists(): @@ -2979,9 +2986,6 @@ def py_source(self, custom_functions=None, indent=""): command += arg.py_arg_name command += "}" command += '"\n' - while command != command.replace(',"', '"'): # remove extra commas at the end of the command - command = command.replace(',"', '"') - # ",{" + "},{".join(self.arg_desc.py_arg_name) + '}"\n' else: command = 'command = f"' + self.name + '"\n' return_command = "return self.run(command, **kwargs)\n"