Matthias Kuhn bb79d13e82 Remove deprecated Qgis::WKBType and API cleanup (#3325)
* Remove deprecated Qgis::WKBType and API cleanup

Renames QgsWKBTypes to QgsWkbTypes

Replaces usage of the enums:

* Qgis::WKBType with QgsWkbTypes::Type
* Qgis::GeometryType with QgsWkbTypes::GeometryType

Their values should be forward compatible (a fact that was already
explited up to now by casting between the types)

Renames some SSLxxx to SslXxx and URIxxx to UriXxx

* Fix build warnings and simplify type handling

* Add a fixer to rewrite imports

* The forgotten rebase conflictThe forgotten rebase conflicts

* QgsDataSourcURI > QgsDataSourceUri

* QgsWKBTypes > QgsWkbTypes

* Qgis.WKBGeom > QgsWkbTypes.Geom

* Further python fixes

* Guess what... Qgis::wkbDimensions != QgsWkbTypes::wkbDimensions

* Fix tests

* Python 3 updates

* [travis] pull request caching cannot be disabled

so at least use it in r/w mode

* Fix python3 print in plugins
2016-08-04 09:10:08 +02:00

94 lines
3.0 KiB
Python

# -*- coding: utf-8 -*-
"""
***************************************************************************
general.py
---------------------
Date : April 2013
Copyright : (C) 2013 by Victor Olaya
Email : volayaf at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************
"""
from __future__ import print_function
__author__ = 'Victor Olaya'
__date__ = 'April 2013'
__copyright__ = '(C) 2013, Victor Olaya'
# This will get replaced with a git SHA1 when you do a git archive
__revision__ = '$Format:%H$'
import os
try:
import configparser
except ImportError:
import ConfigParser as configparser
from processing.core.Processing import Processing
from processing.core.alglist import algList
from processing.core.parameters import ParameterSelection
from processing.gui.Postprocessing import handleAlgorithmResults
def alglist(text=None):
s = ''
for provider in algList.algs.values():
sortedlist = sorted(provider.values(), key=lambda alg: alg.name)
for alg in sortedlist:
if text is None or text.lower() in alg.name.lower():
s += alg.name.ljust(50, '-') + '--->' + alg.commandLineName() \
+ '\n'
print(s)
def algoptions(name):
alg = Processing.getAlgorithm(name)
if alg is not None:
s = ''
for param in alg.parameters:
if isinstance(param, ParameterSelection):
s += param.name + '(' + param.description + ')\n'
i = 0
for option in param.options:
s += '\t' + unicode(i) + ' - ' + unicode(option) + '\n'
i += 1
print(s)
else:
print('Algorithm not found')
def alghelp(name):
alg = Processing.getAlgorithm(name)
if alg is not None:
alg = alg.getCopy()
print(unicode(alg))
algoptions(name)
else:
print('Algorithm not found')
def runalg(algOrName, *args, **kwargs):
alg = Processing.runAlgorithm(algOrName, None, *args, **kwargs)
if alg is not None:
return alg.getOutputValuesAsDictionary()
def runandload(name, *args, **kwargs):
return Processing.runAlgorithm(name, handleAlgorithmResults, *args, **kwargs)
def version():
pluginPath = os.path.split(os.path.dirname(__file__))[0]
cfg = configparser.SafeConfigParser()
cfg.read(os.path.join(pluginPath, 'metadata.txt'))
ver = cfg.get('general', 'version').split('.')
return 10000 * int(ver[0]) + 100 * int(ver[1]) + int(ver[2])