[GRASS-SVN] r56695 - in grass/trunk/gui/wxpython: core dbmgr gui_core

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 14 01:29:45 PDT 2013


Author: hamish
Date: 2013-06-14 01:29:44 -0700 (Fri, 14 Jun 2013)
New Revision: 56695

Modified:
   grass/trunk/gui/wxpython/core/settings.py
   grass/trunk/gui/wxpython/dbmgr/base.py
   grass/trunk/gui/wxpython/gui_core/preferences.py
Log:
#1633: make it very unlikely that field sep will collide with values in the ascii flat table, without requiring user intervention (merge from devbr6)

Modified: grass/trunk/gui/wxpython/core/settings.py
===================================================================
--- grass/trunk/gui/wxpython/core/settings.py	2013-06-14 06:55:04 UTC (rev 56694)
+++ grass/trunk/gui/wxpython/core/settings.py	2013-06-14 08:29:44 UTC (rev 56695)
@@ -227,9 +227,6 @@
                     },
                 'encoding' : {
                     'value' : '',
-                    },
-                'fieldSeparator' : {
-                    'value' : '|',
                     }
                 },
             #

Modified: grass/trunk/gui/wxpython/dbmgr/base.py
===================================================================
--- grass/trunk/gui/wxpython/dbmgr/base.py	2013-06-14 06:55:04 UTC (rev 56694)
+++ grass/trunk/gui/wxpython/dbmgr/base.py	2013-06-14 08:29:44 UTC (rev 56695)
@@ -163,20 +163,23 @@
         except:
             keyId = -1
         
-        fs = UserSettings.Get(group = 'atm', key = 'fieldSeparator', subkey = 'value')
         # read data
         # FIXME: Max. number of rows, while the GUI is still usable
 
         # stdout can be very large, do not use PIPE, redirect to temp file
         # TODO: more effective way should be implemented...
+
+        # split on field sep breaks if varchar() column contains the
+        # values, so while sticking with ASCII we make it something
+        # highly unlikely to exist naturally.
+        fs = '{_sep_}'
+
         outFile = tempfile.NamedTemporaryFile(mode = 'w+b')
 
         cmdParams = dict(quiet = True,
                          parent = self,
-                         flags = 'c')
-        # pipe must not be given in the params for windows
-        if not (sys.platform == "win32" and fs == '|'):
-            cmdParams.update(dict(sep = fs))
+                         flags = 'c',
+                         separator = fs)
 
         if sql:
             cmdParams.update(dict(sql = sql,
@@ -234,9 +237,7 @@
             if len(columns) != len(record):
                 GError(parent = self,
                        message = _("Inconsistent number of columns "
-                                   "in the table <%(table)s>. "
-                                   "Try to change field separator in GUI Settings, "
-                                   "Attributes tab, Data browser section.") % \
+                                   "in the table <%(table)s>.") % \
                                {'table' : tableName })
                 self.columns = {} # because of IsEmpty method
                 return
@@ -245,7 +246,7 @@
 
             i += 1
             if i >= 100000:
-                self.log.write(_("Limit 100000 records."))
+                self.log.write(_("Viewing limit: 100000 records."))
                 break
         
         self.SetItemCount(i)

Modified: grass/trunk/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/trunk/gui/wxpython/gui_core/preferences.py	2013-06-14 06:55:04 UTC (rev 56694)
+++ grass/trunk/gui/wxpython/gui_core/preferences.py	2013-06-14 08:29:44 UTC (rev 56695)
@@ -45,7 +45,7 @@
 from grass.script import core as grass
 
 from core          import globalvar
-from core.gcmd     import RunCommand, GError
+from core.gcmd     import RunCommand
 from core.utils    import ListOfMapsets, GetColorTables, ReadEpsgCodes, StoreEnvVariable
 from core.settings import UserSettings
 from gui_core.dialogs import SymbolDialog
@@ -215,15 +215,6 @@
                               caption = _("Error"), style = wx.OK | wx.ICON_ERROR)
                 win.SetValue(self.settings.Get(group = 'atm', key = 'keycolumn', subkey = 'value'))
                 return False
-            if key == 'fieldSeparator':
-                try:
-                    value = str(value)
-                except UnicodeEncodeError:
-                    GError(parent = self, message = _("Field separator must be ASCII character "
-                                                      "not <%s> (use e.g. ';', '&', '#')") % value)
-                    return False
-                if value == '':
-                    value = self.settings.Get(group = 'atm', key = 'fieldSeparator', subkey = 'value')
             if subkey1:
                 self.settings.Set(group, value, key, [subkey, subkey1])
             else:
@@ -1154,17 +1145,6 @@
         flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
         flexSizer.Add(encoding, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
 
-        # field separator
-        label = wx.StaticText(parent = panel, id = wx.ID_ANY,
-                              label = _("Field separator:"))
-        separator = wx.TextCtrl(parent = panel, id = wx.ID_ANY,
-                                value = self.settings.Get(group = 'atm', key = 'fieldSeparator', subkey = 'value'),
-                                name = "GetValue", size = (200, -1))
-        self.winId['atm:fieldSeparator:value'] = separator.GetId()
-
-        flexSizer.Add(label, proportion = 0, flag = wx.ALIGN_CENTER_VERTICAL)
-        flexSizer.Add(separator, proportion = 0, flag = wx.ALIGN_RIGHT | wx.FIXED_MINSIZE)
-
         # ask on delete record
         askOnDeleteRec = wx.CheckBox(parent = panel, id = wx.ID_ANY,
                                      label = _("Ask when deleting data record(s) from table"),



More information about the grass-commit mailing list