[GRASS-SVN] r42167 -
grass/branches/develbranch_6/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat May 8 15:28:02 EDT 2010
Author: martinl
Date: 2010-05-08 15:28:01 -0400 (Sat, 08 May 2010)
New Revision: 42167
Modified:
grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
Log:
wxGUI: get gdal formats on request
(merge r42165 from trunk)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py 2010-05-08 19:25:59 UTC (rev 42166)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/globalvar.py 2010-05-08 19:28:01 UTC (rev 42167)
@@ -158,59 +158,3 @@
have_mlist = True
else:
have_mlist = False
-
-def _getGDALFormats():
- """!Get dictionary of avaialble GDAL drivers"""
- if not grass.find_program('r.in.gdal'):
- return _parseFormats(None)
-
- ret = grass.read_command('r.in.gdal',
- quiet = True,
- flags = 'f')
-
- return _parseFormats(ret)
-
-def _getOGRFormats():
- """!Get dictionary of avaialble OGR drivers"""
- if not grass.find_program('v.in.ogr'):
- return _parseFormats(None)
-
- ret = grass.read_command('v.in.ogr',
- quiet = True,
- flags = 'f')
-
- return _parseFormats(ret)
-
-def _parseFormats(output):
- """!Parse r.in.gdal/v.in.ogr -f output"""
- formats = { 'file' : list(),
- 'database' : list(),
- 'protocol' : list()
- }
-
- if not output:
- return formats
-
- for line in output.splitlines():
- format = line.strip().rsplit(':', -1)[1].strip()
- if format in ('Memory', 'Virtual Raster', 'In Memory Raster'):
- continue
- if format in ('PostgreSQL', 'SQLite',
- 'ODBC', 'ESRI Personal GeoDatabase',
- 'Rasterlite',
- 'PostGIS WKT Raster driver'):
- formats['database'].append(format)
- elif format in ('GeoJSON',
- 'OGC Web Coverage Service',
- 'OGC Web Map Service',
- 'HTTP Fetching Wrapper'):
- formats['protocol'].append(format)
- else:
- formats['file'].append(format)
-
- return formats
-
-formats = {
- 'gdal' : _getGDALFormats(),
- 'ogr' : _getOGRFormats()
- }
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2010-05-08 19:25:59 UTC (rev 42166)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/gselect.py 2010-05-08 19:28:01 UTC (rev 42167)
@@ -790,7 +790,7 @@
ftype = 'gdal'
formats = list()
- for f in globalvar.formats[ftype].values():
+ for f in utils.GetFormats()[ftype].values():
formats += f
self.SetItems(formats)
@@ -970,16 +970,16 @@
fType = 'gdal'
self.input = { 'file' : [_("File:"),
dsnFile,
- globalvar.formats[fType]['file']],
+ utils.GetFormats()[fType]['file']],
'dir' : [_("Directory:"),
dsnDir,
- globalvar.formats[fType]['file']],
+ utils.GetFormats()[fType]['file']],
'db' : [_("Database:"),
dsnDbFile,
- globalvar.formats[fType]['database']],
+ utils.GetFormats()[fType]['database']],
'pro' : [_("Protocol:"),
dsnPro,
- globalvar.formats[fType]['protocol']],
+ utils.GetFormats()[fType]['protocol']],
'db-win' : { 'file' : dsnDbFile,
'text' : dsnDbText,
'choice' : dsnDbChoice },
Modified: grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2010-05-08 19:25:59 UTC (rev 42166)
+++ grass/branches/develbranch_6/gui/wxpython/gui_modules/utils.py 2010-05-08 19:28:01 UTC (rev 42167)
@@ -645,3 +645,67 @@
return unicode(string, enc)
return string
+
+def _getGDALFormats():
+ """!Get dictionary of avaialble GDAL drivers"""
+ if not grass.find_program('r.in.gdal'):
+ return _parseFormats(None)
+
+ ret = grass.read_command('r.in.gdal',
+ quiet = True,
+ flags = 'f')
+
+ return _parseFormats(ret)
+
+def _getOGRFormats():
+ """!Get dictionary of avaialble OGR drivers"""
+ if not grass.find_program('v.in.ogr'):
+ return _parseFormats(None)
+
+ ret = grass.read_command('v.in.ogr',
+ quiet = True,
+ flags = 'f')
+
+ return _parseFormats(ret)
+
+def _parseFormats(output):
+ """!Parse r.in.gdal/v.in.ogr -f output"""
+ formats = { 'file' : list(),
+ 'database' : list(),
+ 'protocol' : list()
+ }
+
+ if not output:
+ return formats
+
+ for line in output.splitlines():
+ format = line.strip().rsplit(':', -1)[1].strip()
+ if format in ('Memory', 'Virtual Raster', 'In Memory Raster'):
+ continue
+ if format in ('PostgreSQL', 'SQLite',
+ 'ODBC', 'ESRI Personal GeoDatabase',
+ 'Rasterlite',
+ 'PostGIS WKT Raster driver'):
+ formats['database'].append(format)
+ elif format in ('GeoJSON',
+ 'OGC Web Coverage Service',
+ 'OGC Web Map Service',
+ 'HTTP Fetching Wrapper'):
+ formats['protocol'].append(format)
+ else:
+ formats['file'].append(format)
+
+ return formats
+
+formats = None
+
+def GetFormats():
+ """!Get GDAL/OGR formats"""
+ global formats
+ if not formats:
+ formats = {
+ 'gdal' : _getGDALFormats(),
+ 'ogr' : _getOGRFormats()
+ }
+
+ return formats
More information about the grass-commit
mailing list