def postproConfigAddFileCallback(self, new_name): """ Callback function called whenever the user wants to add a new file in the postprocessor config window. It creates the new file from scratch, then reaload the list of configuration files and select the new file @param: the new filename """ result = True new_name += c.CONFIG_EXTENSION #Add the extension if new_name not in self.getConfigsList()['filename']: logger.debug( "New postprocessor config file {0} is going to be created". format(new_name)) postpro_config = MyPostProConfig(filename=new_name) postpro_config.create_default_config() postpro_config.default_config = True self.loadCreateConfigFiles() self.config_postpro_window.setConfigSelectorFilesList( self.getConfigsList(), new_name) #Set the list of current configuration files else: #File already exists result = False return result
def getPostProVars(self, file_index): """ Get the parameters of the Postprocessor Config File @param file_index: The index of the file to read and write variables in self.vars. """ PostProConfig = MyPostProConfig(filename=self.postprocessor_files[file_index]) PostProConfig.load_config() self.vars = PostProConfig.vars
def get_output_vars(self): """ Reads all Postprocessor Config Files located in the PostProcessor Config Directory and creates a list of the possible output formats. """ for postprocessor_file in self.postprocessor_files: PostProConfig = MyPostProConfig(filename=postprocessor_file) PostProConfig.load_config() self.version_mismatch += PostProConfig.version_mismatch # Get possible version error encountered when opening the file self.output_format.append(PostProConfig.vars.General['output_format']) self.output_text.append(PostProConfig.vars.General['output_text'])
def get_output_vars(self): """ Reads all Postprocessor Config Files located in the PostProcessor Config Directory and creates a list of the possible output formats. """ self.output_format = [] self.output_text = [] for postprocessor_file in self.postprocessor_files: PostProConfig = MyPostProConfig(filename=postprocessor_file) PostProConfig.load_config() self.output_format.append(PostProConfig.vars.General['output_format']) self.output_text.append(PostProConfig.vars.General['output_text'])
def __init__(self): """ The initialisation of the Postprocessor class. This function is called during the initialisation of the Main Window. It checks during the initialization if a PostProcessor Config file exists and if not creates a new one. For the Save function it creates a list of all possible Postprocessor Config Files. """ self.version_mismatch = '' # no problem for now self.postprocessor_files = [] # store the postprocessors filenames self.output_format = [ ] # store the postprocessors filenames extensions self.output_text = [] # store the postprocessors descriptions # Load the existing postprocessor config files, or create a new one self.loadCreateConfigFiles() self.config_postpro_window = ConfigWindow( MyPostProConfig.makeConfigWidgets(), title=self.tr("Postprocessor configuration")) #Enable the config file selector into the configuration widget self.config_postpro_window.setConfigSelectorCallback( self.postproConfigSelectionChangedCallback, self.postproConfigAddFileCallback, self.postproConfigRemoveFileCallback, self.postproConfigDuplicateFileCallback) self.config_postpro_window.setConfigSelectorFilesList( self.getConfigsList() ) #Set the list of current configuration files self.config_postpro_window.finished.connect( self.updatePostprocessorConfiguration)
def __init__(self): """ The initialisation of the Postprocessor class. This function is called during the initialisation of the Main Window. It checks during the initialization if a PostProcessor Config file exists and if not creates a new one. For the Save function it creates a list of all possible Postprocessor Config Files. """ try: lfiles = sorted( os.listdir(os.path.join(g.folder, c.DEFAULT_POSTPRO_DIR))) """ FIXME Folder needs to be empty or valid config file within. """ # logger.debug(lfiles) except: # Create a Postprocessor File if none found in folder logger.debug(self.tr("created default varspace")) PostProConfig = MyPostProConfig() PostProConfig.create_default_config() PostProConfig.default_config = True lfiles = os.listdir(PostProConfig.folder) # Only files with the predefined extension, stated in c.CONFIG_EXTENSION # (default .cfg), are accepted self.postprocessor_files = [] for lfile in lfiles: if os.path.splitext(lfile)[1] == c.CONFIG_EXTENSION: self.postprocessor_files.append(lfile) if len(self.postprocessor_files) == 0: PostProConfig = MyPostProConfig() PostProConfig.create_default_config() PostProConfig.default_config = True lfiles = os.listdir(PostProConfig.folder) self.postprocessor_files = [] for lfile in lfiles: if os.path.splitext(lfile)[1] == c.CONFIG_EXTENSION: self.postprocessor_files.append(lfile) # Load all files to get the possible postprocessor configs to export self.get_output_vars()
def loadCreateConfigFiles(self): """ Load the existing postprocessor config files, or create a new one """ del self.postprocessor_files[:] # store the postprocessors filenames del self.output_format[:] # store the postprocessors filenames extensions del self.output_text[:] # store the postprocessors descriptions try: lfiles = sorted( os.listdir(os.path.join(g.folder, c.DEFAULT_POSTPRO_DIR))) """ FIXME Folder needs to be empty or valid config file within. """ # logger.debug(lfiles) except: # Create a Postprocessor File if none found in folder logger.debug(self.tr("created default varspace")) PostProConfig = MyPostProConfig() PostProConfig.create_default_config() PostProConfig.default_config = True lfiles = os.listdir(PostProConfig.folder) # Only files with the predefined extension, stated in c.CONFIG_EXTENSION # (default .cfg), are accepted for lfile in lfiles: if os.path.splitext(lfile)[1] == c.CONFIG_EXTENSION: self.postprocessor_files.append(lfile) if len(self.postprocessor_files) == 0: PostProConfig = MyPostProConfig() PostProConfig.create_default_config() PostProConfig.default_config = True lfiles = os.listdir(PostProConfig.folder) self.postprocessor_files = [] for lfile in lfiles: if os.path.splitext(lfile)[1] == c.CONFIG_EXTENSION: self.postprocessor_files.append(lfile) # Load all files to get the possible postprocessor configs to export self.get_output_vars()
def __init__(self): """ The initialisation of the Postprocessor class. This function is called during the initialisation of the Main Window. It checks during the initialization if a PostProcessor Config file exists and if not creates a new one. For the Save function it creates a list of all possible Postprocessor Config Files. """ try: lfiles = sorted(os.listdir(os.path.join(g.folder, c.DEFAULT_POSTPRO_DIR))) """ FIXME Folder needs to be empty or valid config file within. """ # logger.debug(lfiles) except: # Create a Postprocessor File if none found in folder logger.debug(self.tr("created default varspace")) PostProConfig = MyPostProConfig() PostProConfig.create_default_config() PostProConfig.default_config = True lfiles = os.listdir(PostProConfig.folder) # Only files with the predefined extension, stated in c.CONFIG_EXTENSION # (default .cfg), are accepted self.postprocessor_files = [] for lfile in lfiles: if os.path.splitext(lfile)[1] == c.CONFIG_EXTENSION: self.postprocessor_files.append(lfile) if len(self.postprocessor_files) == 0: PostProConfig = MyPostProConfig() PostProConfig.create_default_config() PostProConfig.default_config = True lfiles = os.listdir(PostProConfig.folder) self.postprocessor_files = [] for lfile in lfiles: if os.path.splitext(lfile)[1] == c.CONFIG_EXTENSION: self.postprocessor_files.append(lfile) # Load all files to get the possible postprocessor configs to export self.get_output_vars()