mirror of
https://github.com/qgis/QGIS.git
synced 2025-05-01 00:02:48 -04:00
[processing] replace str() with unicode() to avoid possible issues with
non-ASCII characters (work in progress)
This commit is contained in:
parent
3480ef2e47
commit
2d835fbae0
@ -54,15 +54,15 @@ class OgrAlgorithm(GdalAlgorithm):
|
|||||||
if provider == 'spatialite':
|
if provider == 'spatialite':
|
||||||
# dbname='/geodata/osm_ch.sqlite' table="places" (Geometry) sql=
|
# dbname='/geodata/osm_ch.sqlite' table="places" (Geometry) sql=
|
||||||
regex = re.compile("dbname='(.+)'")
|
regex = re.compile("dbname='(.+)'")
|
||||||
r = regex.search(str(layer.source()))
|
r = regex.search(unicode(layer.source()))
|
||||||
ogrstr = r.groups()[0]
|
ogrstr = r.groups()[0]
|
||||||
elif provider == 'postgres':
|
elif provider == 'postgres':
|
||||||
# dbname='ktryjh_iuuqef' host=spacialdb.com port=9999
|
# dbname='ktryjh_iuuqef' host=spacialdb.com port=9999
|
||||||
# user='ktryjh_iuuqef' password='xyqwer' sslmode=disable
|
# user='ktryjh_iuuqef' password='xyqwer' sslmode=disable
|
||||||
# key='gid' estimatedmetadata=true srid=4326 type=MULTIPOLYGON
|
# key='gid' estimatedmetadata=true srid=4326 type=MULTIPOLYGON
|
||||||
# table="t4" (geom) sql=
|
# table="t4" (geom) sql=
|
||||||
s = re.sub(''' sslmode=.+''', '', str(layer.source()))
|
s = re.sub(''' sslmode=.+''', '', unicode(layer.source()))
|
||||||
ogrstr = 'PG:%s' % s
|
ogrstr = 'PG:%s' % s
|
||||||
else:
|
else:
|
||||||
ogrstr = str(layer.source())
|
ogrstr = unicode(layer.source())
|
||||||
return ogrstr
|
return ogrstr
|
||||||
|
@ -53,7 +53,7 @@ class Output(object):
|
|||||||
# in a vector layer). In the case of layers, hidden outputs are
|
# in a vector layer). In the case of layers, hidden outputs are
|
||||||
# not loaded into QGIS after the algorithm is executed. Other
|
# not loaded into QGIS after the algorithm is executed. Other
|
||||||
# outputs not representing layers or tables should always be hidden.
|
# outputs not representing layers or tables should always be hidden.
|
||||||
self.hidden = str(hidden).lower() == str(True).lower()
|
self.hidden = unicode(hidden).lower() == unicode(True).lower()
|
||||||
|
|
||||||
# This value indicates whether the output has to be opened
|
# This value indicates whether the output has to be opened
|
||||||
# after being produced by the algorithm or not
|
# after being produced by the algorithm or not
|
||||||
@ -64,12 +64,12 @@ class Output(object):
|
|||||||
|
|
||||||
def getValueAsCommandLineParameter(self):
|
def getValueAsCommandLineParameter(self):
|
||||||
if self.value is None:
|
if self.value is None:
|
||||||
return str(None)
|
return unicode(None)
|
||||||
else:
|
else:
|
||||||
if not isWindows():
|
if not isWindows():
|
||||||
return '"' + str(self.value) + '"'
|
return '"' + unicode(self.value) + '"'
|
||||||
else:
|
else:
|
||||||
return '"' + str(self.value).replace('\\', '\\\\') + '"'
|
return '"' + unicode(self.value).replace('\\', '\\\\') + '"'
|
||||||
|
|
||||||
def setValue(self, value):
|
def setValue(self, value):
|
||||||
try:
|
try:
|
||||||
@ -99,7 +99,7 @@ class OutputExtent(Output):
|
|||||||
if value is not None and isinstance(value, basestring):
|
if value is not None and isinstance(value, basestring):
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
else:
|
else:
|
||||||
self.value = ','.join([str(v) for v in value])
|
self.value = ','.join([unicode(v) for v in value])
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
@ -39,9 +39,9 @@ def getParameterFromString(s):
|
|||||||
return clazz(*params)
|
return clazz(*params)
|
||||||
|
|
||||||
def parseBool(s):
|
def parseBool(s):
|
||||||
if s == str(None):
|
if s == unicode(None):
|
||||||
return None
|
return None
|
||||||
return str(s).lower() == str(True).lower()
|
return unicode(s).lower() == unicode(True).lower()
|
||||||
|
|
||||||
|
|
||||||
class Parameter:
|
class Parameter:
|
||||||
@ -69,7 +69,7 @@ class Parameter:
|
|||||||
Returns true if the value passed is correct for the type
|
Returns true if the value passed is correct for the type
|
||||||
of parameter.
|
of parameter.
|
||||||
"""
|
"""
|
||||||
self.value = str(obj)
|
self.value = unicode(obj)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
@ -81,7 +81,7 @@ class Parameter:
|
|||||||
entered in the console if calling an algorithm using the
|
entered in the console if calling an algorithm using the
|
||||||
Processing.runalg() method.
|
Processing.runalg() method.
|
||||||
"""
|
"""
|
||||||
return str(self.value)
|
return unicode(self.value)
|
||||||
|
|
||||||
def parameterName(self):
|
def parameterName(self):
|
||||||
return self.__module__.split('.')[-1]
|
return self.__module__.split('.')[-1]
|
||||||
@ -102,7 +102,7 @@ class ParameterBoolean(Parameter):
|
|||||||
self.value = self.default
|
self.value = self.default
|
||||||
return True
|
return True
|
||||||
if isinstance(value, basestring):
|
if isinstance(value, basestring):
|
||||||
self.value = str(value).lower() == str(True).lower()
|
self.value = unicode(value).lower() == unicode(True).lower()
|
||||||
else:
|
else:
|
||||||
self.value = bool(value)
|
self.value = bool(value)
|
||||||
return True
|
return True
|
||||||
@ -122,18 +122,18 @@ class ParameterCrs(Parameter):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# TODO: check it is a valid authid
|
# TODO: check it is a valid authid
|
||||||
self.value = str(value)
|
self.value = unicode(value)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getValueAsCommandLineParameter(self):
|
def getValueAsCommandLineParameter(self):
|
||||||
return '"' + str(self.value) + '"'
|
return '"' + unicode(self.value) + '"'
|
||||||
|
|
||||||
|
|
||||||
class ParameterDataObject(Parameter):
|
class ParameterDataObject(Parameter):
|
||||||
|
|
||||||
def getValueAsCommandLineParameter(self):
|
def getValueAsCommandLineParameter(self):
|
||||||
if self.value is None:
|
if self.value is None:
|
||||||
return str(None)
|
return unicode(None)
|
||||||
else:
|
else:
|
||||||
if not isWindows():
|
if not isWindows():
|
||||||
return '"' + unicode(self.value) + '"'
|
return '"' + unicode(self.value) + '"'
|
||||||
@ -168,7 +168,7 @@ class ParameterExtent(Parameter):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def getValueAsCommandLineParameter(self):
|
def getValueAsCommandLineParameter(self):
|
||||||
return '"' + str(self.value) + '"'
|
return '"' + unicode(self.value) + '"'
|
||||||
|
|
||||||
class ParameterFile(Parameter):
|
class ParameterFile(Parameter):
|
||||||
|
|
||||||
@ -214,7 +214,7 @@ class ParameterFixedTable(Parameter):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
def getValueAsCommandLineParameter(self):
|
def getValueAsCommandLineParameter(self):
|
||||||
return '"' + str(self.value) + '"'
|
return '"' + unicode(self.value) + '"'
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def tableToString(table):
|
def tableToString(table):
|
||||||
@ -362,7 +362,7 @@ class ParameterNumber(Parameter):
|
|||||||
default=0.0):
|
default=0.0):
|
||||||
Parameter.__init__(self, name, description)
|
Parameter.__init__(self, name, description)
|
||||||
try:
|
try:
|
||||||
self.default = int(str(default))
|
self.default = int(unicode(default))
|
||||||
self.isInteger = True
|
self.isInteger = True
|
||||||
except:
|
except:
|
||||||
self.default = float(default)
|
self.default = float(default)
|
||||||
@ -415,7 +415,7 @@ class ParameterRange(Parameter):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def getValueAsCommandLineParameter(self):
|
def getValueAsCommandLineParameter(self):
|
||||||
return '"' + str(self.value) + '"'
|
return '"' + unicode(self.value) + '"'
|
||||||
|
|
||||||
|
|
||||||
class ParameterRaster(ParameterDataObject):
|
class ParameterRaster(ParameterDataObject):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user