Exemplo n.º 1
0
    def process_metadata_line(self, line):
        """
        Processes a "metadata" (##) line
        """
        line = line.replace('#', '')

        # special commands
        if line.lower().strip().startswith('showplots'):
            self.show_plots = True
            self.addParameter(
                QgsProcessingParameterFileDestination(
                    RAlgorithm.RPLOTS,
                    self.tr('R Plots'),
                    self.tr('HTML files (*.html)'),
                    optional=True))
            return
        if line.lower().strip().startswith('dontuserasterpackage'):
            self.use_raster_package = False
            return
        if line.lower().strip().startswith('passfilenames'):
            self.pass_file_names = True
            return

        value, type_ = self.split_tokens(line)
        if type_.lower().strip() == 'group':
            self._group = value
            return
        if type_.lower().strip() == 'name':
            self._name = self._display_name = value
            self._name = RUtils.strip_special_characters(self._name.lower())
            return

        self.process_parameter_line(line)
Exemplo n.º 2
0
    def process_metadata_line(self, line):  # pylint: disable=too-many-return-statements
        """
        Processes a "metadata" (##) line
        """
        line = line.replace('#', '')

        # special commands
        # showplots is the older version, should be considere obsolete
        if line.lower().strip().startswith('output_plots_to_html') or \
           line.lower().strip().startswith('showplots'):
            self.show_plots = True
            self.addParameter(
                QgsProcessingParameterFileDestination(
                    RAlgorithm.RPLOTS,
                    self.tr('R Plots'),
                    self.tr('HTML files (*.html)'),
                    optional=True))
            return

        # dontuserasterpackage is the older version, should be considere obsolete
        if line.lower().strip().startswith('load_raster_using_rgdal') or \
           line.lower().strip().startswith('dontuserasterpackage'):
            self.r_templates.use_raster = False
            return

        if line.lower().strip().startswith('load_vector_using_rgdal'):
            self.r_templates.use_sf = False
            return

        # passfilenames is the older version, should be considere obsolete
        if line.lower().strip().startswith('pass_filenames') or\
           line.lower().strip().startswith('passfilenames'):
            self.pass_file_names = True
            return

        if line.lower().strip().startswith('dont_load_any_packages'):
            self.r_templates.auto_load_packages = False
            return

        value, type_ = self.split_tokens(line)
        if type_.lower().strip() == 'group':
            self._group = value
            return
        if type_.lower().strip() == 'name':
            self._name = self._display_name = value
            self._name = RUtils.strip_special_characters(self._name.lower())
            return
        if type_.lower().strip() == 'display_name':
            self._display_name = value
            return
        if type_.lower().strip() == 'github_install':
            self.r_templates.install_github = True
            self.r_templates.github_dependencies = value
            return

        # process enum with values and preparing its template
        if "=enum literal" in RUtils.upgrade_parameter_line(line):
            self.r_templates.add_literal_enum(value)

        self.process_parameter_line(line)
Exemplo n.º 3
0
 def testStripSpecialCharacters(self):
     """
     Tests stripping special characters from a name
     """
     self.assertEqual(RUtils.strip_special_characters('aB 43 24a:sd'), 'aB4324asd')