def createGeneratorDataObject(self): # Collect the settings the user has made and build the Data Object result = GeneratorDataObject( scribusSourceFile=self.__scribusSourceFileEntryVariable.get(), dataSourceFile=self.__dataSourceFileEntryVariable.get(), outputDirectory=self.__outputDirectoryEntryVariable.get(), outputFileName=self.__outputFileNameEntryVariable.get(), outputFormat=self.__selectedOutputFormat.get(), keepGeneratedScribusFiles=self. __keepGeneratedScribusFilesCheckboxVariable.get(), csvSeparator=self.__dataSeparatorEntryVariable.get(), singleOutput=self.__mergeOutputCheckboxVariable.get(), firstRow=self.__fromVariable.get(), lastRow=self.__toVariable.get(), saveSettings=self.__saveCheckboxVariable.get()) return result
def scribusLoadSettingsHandler(self): slaFile = self.__scribusSourceFileEntryVariable.get() if (slaFile is CONST.EMPTY): tkMessageBox.showinfo( 'Choose a file', message= "Set a valid scribus input file prior to loading its settings." ) return dataObject = GeneratorDataObject(scribusSourceFile=slaFile) generator = ScribusGenerator(dataObject) saved = generator.getSavedSettings() if (saved): dataObject.loadFromString(saved) # self.__scribusSourceFileEntryVariable = StringVar() #not loaded self.__dataSourceFileEntryVariable.set( dataObject.getDataSourceFile()) self.__dataSeparatorEntryVariable.set(dataObject.getCsvSeparator()) self.__outputDirectoryEntryVariable.set( dataObject.getOutputDirectory()) self.__outputFileNameEntryVariable.set( dataObject.getOutputFileName()) self.__selectedOutputFormat.set(dataObject.getOutputFormat()) self.__keepGeneratedScribusFilesCheckboxVariable.set( dataObject.getKeepGeneratedScribusFiles()) self.__mergeOutputCheckboxVariable.set( dataObject.getSingleOutput()) # self.__saveCheckboxVariable = IntVar() #not loaded self.__fromVariable.set(dataObject.getFirstRow()) self.__toVariable.set(dataObject.getLastRow()) else: tkMessageBox.showinfo( 'No Settings', message="Input scribus file contains no former saved settings." )
) sys.exit() # create outDir if needed if (not (args.outDir is None)) and (not os.path.exists(args.outDir)): # print('creating output directory: '+args.outDir) os.makedirs(args.outDir) # generate # Collect the settings made and build the Data Object dataObject = GeneratorDataObject( dataSourceFile=ife(not (args.csvFile is None), args.csvFile, CONST.EMPTY), outputDirectory=ife(not (args.outDir is None), args.outDir, CONST.EMPTY), outputFileName=args.outName, # is CONST.EMPTY by default outputFormat=ife(args.fast, CONST.FORMAT_SLA, CONST.FORMAT_PDF), keepGeneratedScribusFiles=ife(args.pdfOnly, CONST.FALSE, CONST.TRUE), # not used if outputFormat is sla. csvSeparator=args.csvDelimiter, # is CONST.CSV_SEP by default singleOutput=args.single, firstRow=args.firstRow, lastRow=args.lastRow, ) generator = ScribusGenerator(dataObject) log = generator.getLog() log.debug("ScribusGenerator is starting generation for " + str(len(args.infiles)) + " template(s).") for infile in args.infiles: dataObject.setScribusSourceFile(infile) if args.csvFile is None: # default data file is template-sla+csv dataObject.setDataSourceFile(os.path.splitext(infile)[0] + ".csv") if not (os.path.exists(dataObject.getDataSourceFile()) and os.path.isfile(dataObject.getDataSourceFile())):
# sys.exit() # create outDir if needed if ((not (args.outDir is None)) and (not os.path.exists(args.outDir))): #print('creating output directory: '+args.outDir) os.makedirs(args.outDir) #generate # Collect the settings made and build the Data Object dataObject = GeneratorDataObject( dataSourceFile=ife(not (args.csvFile is None), args.csvFile, CONST.EMPTY), outputDirectory=ife(not (args.outDir is None), args.outDir, CONST.EMPTY), outputFileName=args.outName, # is CONST.EMPTY by default outputFormat=CONST. FORMAT_SLA, # ife(args.fast, CONST.FORMAT_SLA, CONST.FORMAT_PDF), keepGeneratedScribusFiles=CONST. TRUE, # ife(args.pdfOnly, CONST.FALSE, CONST.TRUE), # not used if outputFormat is sla. csvSeparator=args.csvDelimiter, # is CONST.CSV_SEP by default singleOutput=args.merge, firstRow=args.firstRow, lastRow=args.lastRow, saveSettings=args.save) generator = ScribusGenerator(dataObject) log = generator.getLog() log.debug("ScribusGenerator is starting generation for %s template(s)." % (str(len(args.infiles)))) for infile in args.infiles: dataObject.setScribusSourceFile(infile)