[GRASS-SVN] r52815 - in grass/branches/develbranch_6/gui/wxpython: core dbmgr gui_core
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 21 07:04:30 PDT 2012
Author: annakrat
Date: 2012-08-21 07:04:29 -0700 (Tue, 21 Aug 2012)
New Revision: 52815
Modified:
grass/branches/develbranch_6/gui/wxpython/core/settings.py
grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py
grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py
Log:
wxGUI/dbmgr: choose separator for loading table (merge from trunk, r52712, r52730)
Modified: grass/branches/develbranch_6/gui/wxpython/core/settings.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/core/settings.py 2012-08-21 13:06:08 UTC (rev 52814)
+++ grass/branches/develbranch_6/gui/wxpython/core/settings.py 2012-08-21 14:04:29 UTC (rev 52815)
@@ -229,6 +229,9 @@
},
'encoding' : {
'value' : '',
+ },
+ 'fieldSeparator' : {
+ 'value' : '|',
}
},
#
Modified: grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py 2012-08-21 13:06:08 UTC (rev 52814)
+++ grass/branches/develbranch_6/gui/wxpython/dbmgr/manager.py 2012-08-21 14:04:29 UTC (rev 52815)
@@ -117,7 +117,7 @@
# sort item by category (id)
if keyColumn > -1:
self.SortListItems(col = keyColumn, ascending = True)
- else:
+ elif keyColumn:
self.SortListItems(col = 0, ascending = True)
# events
@@ -171,6 +171,7 @@
except:
keyId = -1
+ fs = UserSettings.Get(group = 'atm', key = 'fieldSeparator', subkey = 'value')
#
# read data
#
@@ -185,6 +186,7 @@
quiet = True,
parent = self,
flags = 'c',
+ fs = fs,
sql = sql,
output = outFile.name)
else:
@@ -196,6 +198,7 @@
map = self.mapDBInfo.map,
layer = layer,
columns = ','.join(columns),
+ fs = fs,
where = where,
stdout = outFile)
else:
@@ -205,6 +208,7 @@
flags = 'c',
map = self.mapDBInfo.map,
layer = layer,
+ fs = fs,
where = where,
stdout = outFile)
@@ -242,7 +246,18 @@
if not record:
break
-
+
+ record = record.split(fs)
+ 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.") % \
+ {'table' : tableName })
+ self.columns = {} # because of IsEmpty method
+ return
+
self.AddDataRow(i, record, columns, keyId)
i += 1
@@ -281,7 +296,7 @@
j += 1
cat = i + 1
- for value in record.split('|'):
+ for value in record:
if self.columns[columns[j]]['ctype'] != types.StringType:
try:
### casting disabled (2009/03)
@@ -687,7 +702,7 @@
win = VirtualAttributeList(panel, self.log,
self.mapDBInfo, layer)
if win.IsEmpty():
- del panel
+ panel.Destroy()
continue
win.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.OnDataItemActivated)
Modified: grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py
===================================================================
--- grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py 2012-08-21 13:06:08 UTC (rev 52814)
+++ grass/branches/develbranch_6/gui/wxpython/gui_core/preferences.py 2012-08-21 14:04:29 UTC (rev 52815)
@@ -46,7 +46,7 @@
from grass.script import core as grass
from core import globalvar
-from core.gcmd import RunCommand
+from core.gcmd import RunCommand, GError
from core.utils import ListOfMapsets, GetColorTables, ReadEpsgCodes, GetSettingsPath
from core.settings import UserSettings
@@ -202,6 +202,15 @@
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:
@@ -995,6 +1004,17 @@
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