Skip to content

Commit

Permalink
fix: removing extra argument instead of extra coma
Browse files Browse the repository at this point in the history
  • Loading branch information
clatapie committed Dec 12, 2024
1 parent 09d0ebe commit 371003a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/pyconverter/xml2py/ast_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 371003a

Please sign in to comment.