示例#1
0
    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
示例#2
0
    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()
示例#3
0
    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()
示例#4
0
    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()