[GRASS-SVN] r44556 - grass/trunk/gui/wxpython/gui_modules
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 7 09:14:46 EST 2010
Author: martinl
Date: 2010-12-07 06:14:46 -0800 (Tue, 07 Dec 2010)
New Revision: 44556
Modified:
grass/trunk/gui/wxpython/gui_modules/gdialogs.py
grass/trunk/gui/wxpython/gui_modules/gselect.py
Log:
wxGUI: ext pattern in import dialog case insensitive
(merge r44554 from devbr6)
Modified: grass/trunk/gui/wxpython/gui_modules/gdialogs.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2010-12-07 14:13:19 UTC (rev 44555)
+++ grass/trunk/gui/wxpython/gui_modules/gdialogs.py 2010-12-07 14:14:46 UTC (rev 44556)
@@ -1166,6 +1166,8 @@
else: # gdal
if self.dsnInput.GetType() == 'dir':
idsn = os.path.join(dsn, layer)
+ else:
+ idsn = dsn
if self.link:
cmd = ['r.external',
@@ -1322,7 +1324,7 @@
self.SetStringItem(index, 1, "%s" % str(name))
self.SetStringItem(index, 2, "%s" % str(grassName))
# check by default
- ### self.CheckItem(index, True)
+ self.CheckItem(index, True)
self.SetColumnWidth(col=0, width=wx.LIST_AUTOSIZE_USEHEADER)
Modified: grass/trunk/gui/wxpython/gui_modules/gselect.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/gselect.py 2010-12-07 14:13:19 UTC (rev 44555)
+++ grass/trunk/gui/wxpython/gui_modules/gselect.py 2010-12-07 14:14:46 UTC (rev 44556)
@@ -1008,13 +1008,13 @@
# dsn widgets
if not ogr:
- filemask = 'GeoTIFF (*.tif)|*.tif'
+ filemask = 'GeoTIFF (*.tif)|*.%s' % self._getExtPattern('tif')
else:
- filemask = 'ESRI Shapefile (*.shp)|*.shp'
+ filemask = 'ESRI Shapefile (*.shp)|*.%s' % self._getExtPattern('shp')
dsnFile = filebrowse.FileBrowseButton(parent=self, id=wx.ID_ANY,
size=globalvar.DIALOG_GSELECT_SIZE, labelText = '',
- dialogTitle=_('Choose input file'),
+ dialogTitle=_('Choose file to import'),
buttonText=_('Browse'),
startDirectory=os.getcwd(),
changeCallback=self.OnSetDsn,
@@ -1129,14 +1129,21 @@
self.SetSizer(mainSizer)
mainSizer.Fit(self)
-
+
+ def _getExtPattern(self, ext):
+ """!Get pattern for case-insensitive mask"""
+ pattern = ''
+ for c in ext:
+ pattern += '[' + c + c.upper() + ']'
+
+ return pattern
+
def OnSetType(self, event):
"""!Datasource type changed"""
sel = event.GetSelection()
win = self.input[self.dsnType][1]
self.dsnSizer.Remove(win)
win.Hide()
-
if sel == self.sourceMap['file']: # file
self.dsnType = 'file'
format = self.input[self.dsnType][2][0]
@@ -1144,13 +1151,14 @@
ext = self.format.GetExtension(format)
if not ext:
raise KeyError
- format += ' (*.%s)|*.%s' % (ext, ext)
+ format += ' (*.%s)|*.%s' % (ext, self._getExtPattern(ext))
+ print format
except KeyError:
format += ' (*.*)|*.*'
win = filebrowse.FileBrowseButton(parent=self, id=wx.ID_ANY,
size=globalvar.DIALOG_GSELECT_SIZE, labelText='',
- dialogTitle=_('Choose input file'),
+ dialogTitle=_('Choose file to import'),
buttonText=_('Browse'),
startDirectory=os.getcwd(),
changeCallback=self.OnSetDsn,
@@ -1213,7 +1221,7 @@
ext = self.format.GetExtension(self.format.GetStringSelection())
except KeyError:
ext = ''
- for file in glob.glob(os.path.join(dsn, "*.%s") % ext):
+ for file in glob.glob(os.path.join(dsn, "*.%s") % self._getExtPattern(ext)):
baseName = os.path.basename(file)
grassName = utils.GetValidLayerName(baseName.split('.', -1)[0])
data.append((layerId, baseName, grassName))
@@ -1269,7 +1277,7 @@
ext = self.format.GetExtension(format)
if not ext:
raise KeyError
- format += ' (*.%s)|*.%s' % (ext, ext)
+ format += ' (*.%s)|*.%s' % (ext, self._getExtPattern(ext))
except KeyError:
format += ' (*.*)|*.*'
More information about the grass-commit
mailing list