From 5253ee973c8c76680f253120dd6283fe73df58d1 Mon Sep 17 00:00:00 2001 From: Kristian Rumberg Date: Thu, 14 Aug 2008 09:55:54 +0200 Subject: [PATCH] now gives converted files proper filename extensions --- command_executer.py | 8 +++++--- commands.py | 10 +++++++--- commands.xml | 16 +++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/command_executer.py b/command_executer.py index 63cdf24..acbb89e 100644 --- a/command_executer.py +++ b/command_executer.py @@ -45,8 +45,7 @@ class CommandExecuterView: class CommandExecuter: def mk_unique_subdir(self, parentdir): p = re.compile("[\ ,\/,\(,\)]") - namepart = p.sub("_", self.command.get_name()) - print namepart + namepart = p.sub("_", self.command.get_name()) t = datetime.datetime.now() newdir = parentdir + "/" + namepart + "_" + str(time.mktime(t.timetuple())) @@ -81,7 +80,10 @@ class CommandExecuter: total = len(self.infilelist) for infile in self.infilelist: - outfile = self.outdir + "/" + os.path.basename(infile) + "_converted" + newbase = os.path.basename(infile) + newbase = newbase[0: newbase.rfind(".")] + "." + self.command.get_outfile_extension() + + outfile = self.outdir + "/" + newbase index = index + 1 diff --git a/commands.py b/commands.py index 9859fc3..fb475b5 100644 --- a/commands.py +++ b/commands.py @@ -60,15 +60,19 @@ class OptionalSetting: return instr class Command: - def __init__(self, namestr, callstr, var_list, optset_list): + def __init__(self, namestr, callstr, extstr, var_list, optset_list): self.namestr = namestr self.callstr = callstr + self.extstr = extstr self.var_list = var_list self.optset_list = optset_list def get_name(self): return self.namestr + def get_outfile_extension(self): + return self.extstr + def put_var(self, var): self.var_list[str(var)] = var @@ -156,8 +160,8 @@ class CommandList: elif varsetnode.name != "text": raise Error("Error parsing XML: only variable and optionalsetting elements allowed in command") - props = self._read_properties(cmdnode.properties, ["name", "call"]) - self.cmdcall_dict[props["name"]] = Command(props["name"], props["call"], var_list, optset_list) + props = self._read_properties(cmdnode.properties, ["name", "call", "ext"]) + self.cmdcall_dict[props["name"]] = Command(props["name"], props["call"], props["ext"], var_list, optset_list) else: raise Error("Error parsing XML: only command elements are supported") diff --git a/commands.xml b/commands.xml index 9ef762d..6b4892b 100644 --- a/commands.xml +++ b/commands.xml @@ -1,24 +1,26 @@ - + - + - + - + - + - + - + -- 2.11.4.GIT