Beispiel #1
0
    def initAlgorithm(self, config):
        """
        Here we define the inputs and output of the algorithm, along
        with some other properties.
        """
        self.addParameter(
            QgsProcessingParameterFile(self.INPUT,
                                       self.tr('Input csv file'),
                                       extension='csv'))
        #  encoding of input file
        encParam = QgsProcessingParameterEnum(
            self.ENCODING, self.tr('select encoding of the file'))

        encParam.setOptions(self.encode)
        encParam.setAllowMultiple(False)
        encParam.setDefaultValue(QVariant('SJIS'))
        #  file encoding
        self.addParameter(encParam)

        #self.addParameter(self
        #)

        # We add a feature sink in which to store our processed features (this
        # usually takes the form of a newly created vector layer when the
        # algorithm is run in QGIS).
        self.addParameter(
            QgsProcessingParameterFeatureSink(self.OUTPUT,
                                              self.tr('Output layer')))
Beispiel #2
0
    def initAlgorithm(self, config):
        # Get existing connections
        metadata = QgsProviderRegistry.instance().providerMetadata('postgres')
        names = list(metadata.connections().keys())

        existing_connections = []
        for i, name in enumerate(names):
            if name in connections_list()[0]:
                existing_connections.append(i)

        param = QgsProcessingParameterEnum(
            self.DATABASES,
            'List of databases to look for metadata',
            options=names,
            defaultValue=existing_connections,
        )
        param.setAllowMultiple(True)

        tooltip = tr("PgMetadata can be installed on different databases.")
        if Qgis.QGIS_VERSION_INT >= 31600:
            param.setHelp(tooltip)
        else:
            param.tooltip_3liz = tooltip
        self.addParameter(param)