|
@@ -17,6 +17,7 @@ import sys
|
|
|
import platform
|
|
|
import string
|
|
|
import glob
|
|
|
+import locale
|
|
|
|
|
|
import globalvar
|
|
|
grassPath = os.path.join(globalvar.ETCDIR, "python")
|
|
@@ -465,7 +466,7 @@ def PathJoin(*args):
|
|
|
return path[1].upper() + ':\\' + path[3:].replace('/', '\\')
|
|
|
|
|
|
return path
|
|
|
-
|
|
|
+
|
|
|
def ReadEpsgCodes(path):
|
|
|
"""!Read EPSG code from the file
|
|
|
|
|
@@ -551,13 +552,16 @@ def GetListOfLocations(dbase):
|
|
|
@return list of locations (sorted)
|
|
|
"""
|
|
|
listOfLocations = list()
|
|
|
-
|
|
|
- for location in glob.glob(os.path.join(dbase, "*")):
|
|
|
- try:
|
|
|
- if os.path.join(location, "PERMANENT") in glob.glob(os.path.join(location, "*")):
|
|
|
- listOfLocations.append(os.path.basename(location))
|
|
|
- except:
|
|
|
- pass
|
|
|
+
|
|
|
+ try:
|
|
|
+ for location in glob.glob(os.path.join(dbase, "*")):
|
|
|
+ try:
|
|
|
+ if os.path.join(location, "PERMANENT") in glob.glob(os.path.join(location, "*")):
|
|
|
+ listOfLocations.append(os.path.basename(location))
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+ except UnicodeEncodeError, e:
|
|
|
+ raise e
|
|
|
|
|
|
ListSortLower(listOfLocations)
|
|
|
|
|
@@ -607,3 +611,16 @@ def GetColorTables():
|
|
|
return list()
|
|
|
|
|
|
return ret.splitlines()
|
|
|
+
|
|
|
+def EncodeString(string):
|
|
|
+ """!Return encoded string
|
|
|
+
|
|
|
+ @param string string to be encoded
|
|
|
+
|
|
|
+ @return encoded string
|
|
|
+ """
|
|
|
+ enc = locale.getdefaultlocale()[1]
|
|
|
+ if enc:
|
|
|
+ return string.encode(enc)
|
|
|
+
|
|
|
+ return string
|