[GRASS-SVN] r32726 - in grass/trunk: db/base
gui/wxpython/gui_modules include lib/gis scripts/db.dropcol
scripts/db.droptable
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Aug 12 09:48:43 EDT 2008
Author: martinl
Date: 2008-08-12 09:48:27 -0400 (Tue, 12 Aug 2008)
New Revision: 32726
Modified:
grass/trunk/db/base/columns.c
grass/trunk/db/base/connect.c
grass/trunk/db/base/copy.c
grass/trunk/db/base/describe.c
grass/trunk/db/base/drivers.c
grass/trunk/db/base/execute.c
grass/trunk/db/base/select.c
grass/trunk/db/base/tables.c
grass/trunk/gui/wxpython/gui_modules/menuform.py
grass/trunk/include/gis.h
grass/trunk/lib/gis/parser.c
grass/trunk/scripts/db.dropcol/db.dropcol
grass/trunk/scripts/db.droptable/db.droptable
Log:
gislib: GISPROMPT_DBTABLE defined, various prompt, keywords fixes, wxGUI updated
(merge from devbr6, r32725)
Modified: grass/trunk/db/base/columns.c
===================================================================
--- grass/trunk/db/base/columns.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/db/base/columns.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -81,15 +81,15 @@
driver = G_define_standard_option(G_OPT_DRIVER);
driver->options = db_list_drivers();
if ((drv = db_get_default_driver_name()))
- driver->answer = drv;
+ driver->answer = (char *) drv;
database = G_define_standard_option(G_OPT_DATABASE);
if ((db = db_get_default_database_name()))
- database->answer = db;
+ database->answer = (char *) db;
/* Set description */
module = G_define_module();
- module->keywords = _("database, SQL");
+ module->keywords = _("database, attribute table");
module->description = _("List all columns for a given table.");
if (G_parser(argc, argv))
Modified: grass/trunk/db/base/connect.c
===================================================================
--- grass/trunk/db/base/connect.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/db/base/connect.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -42,7 +42,7 @@
/* Set description */
module = G_define_module();
- module->keywords = _("database, SQL");
+ module->keywords = _("database, attribute table");
module->description =
_("Prints/sets general DB connection for current mapset and exits.");
@@ -58,17 +58,17 @@
driver = G_define_standard_option(G_OPT_DRIVER);
driver->options = db_list_drivers();
- driver->answer = db_get_default_driver_name();
+ driver->answer = (char *) db_get_default_driver_name();
database = G_define_standard_option(G_OPT_DATABASE);
- database->answer = db_get_default_database_name();
+ database->answer = (char *) db_get_default_database_name();
schema = G_define_option();
schema->key = "schema";
schema->type = TYPE_STRING;
schema->required = NO;
schema->multiple = NO;
- schema->answer = db_get_default_schema_name();
+ schema->answer = (char *) db_get_default_schema_name();
schema->label = _("Database schema");
schema->description = _("Do not use this option if schemas "
"are not supported by driver/database server");
@@ -78,7 +78,7 @@
group->type = TYPE_STRING;
group->required = NO;
group->multiple = NO;
- group->answer = db_get_default_group_name();
+ group->answer = (char*) db_get_default_group_name();
group->description = _("Default group of database users to which "
"select privilege is granted");
Modified: grass/trunk/db/base/copy.c
===================================================================
--- grass/trunk/db/base/copy.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/db/base/copy.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -31,74 +31,59 @@
/* Set description */
module = G_define_module();
- module->keywords = _("database, SQL");
+ module->keywords = _("database, attribute table, SQL");
+ module->label = _("Copy a table.");
module->description =
- _("Copy a table. Either 'from_table' (optionaly with 'where') can be used "
- "or 'select' option, but not 'from_table' and 'select' at the same time.");
-
- from_driver = G_define_option();
+ _("Either 'from_table' (optionaly with 'where') can be used "
+ "or 'select' option, but not 'from_table' and 'select' at the same time.");
+
+ from_driver = G_define_standard_option(G_OPT_DRIVER);
from_driver->key = "from_driver";
- from_driver->type = TYPE_STRING;
from_driver->options = db_list_drivers();
- from_driver->required = NO;
from_driver->description = _("Input driver name");
if ((drv = db_get_default_driver_name()))
- from_driver->answer = drv;
+ from_driver->answer = (char *) drv;
- from_database = G_define_option();
+ from_database = G_define_standard_option(G_OPT_DATABASE);
from_database->key = "from_database";
- from_database->type = TYPE_STRING;
- from_database->required = NO;
from_database->description = _("Input database name");
if ((db = db_get_default_database_name()))
- from_database->answer = db;
+ from_database->answer = (char *) db;
- from_table = G_define_option();
+ from_table = G_define_standard_option(G_OPT_TABLE);
from_table->key = "from_table";
- from_table->type = TYPE_STRING;
- from_table->required = NO;
from_table->description =
_("Input table name (only, if 'select' is not used)");
- to_driver = G_define_option();
+ to_driver = G_define_standard_option(G_OPT_DRIVER);
to_driver->key = "to_driver";
- to_driver->type = TYPE_STRING;
to_driver->options = db_list_drivers();
to_driver->required = NO;
to_driver->description = _("Output driver name");
if ((drv = db_get_default_driver_name()))
- to_driver->answer = drv;
+ to_driver->answer = (char *) drv;
- to_database = G_define_option();
+ to_database = G_define_standard_option(G_OPT_DATABASE);
to_database->key = "to_database";
- to_database->type = TYPE_STRING;
- to_database->required = NO;
to_database->description = _("Output database name");
if ((db = db_get_default_database_name()))
- to_database->answer = db;
+ to_database->answer = (char *) db;
- to_table = G_define_option();
+ to_table = G_define_standard_option(G_OPT_TABLE);
to_table->key = "to_table";
- to_table->type = TYPE_STRING;
to_table->required = YES;
to_table->description = _("Output table name");
+ to_table->gisprompt = "new,dbtable,dbtable";
- where = G_define_option();
- where->key = "where";
- where->type = TYPE_STRING;
- where->required = NO;
- where->description =
- _("Optional where condition (without WHERE key word), e.g.:\n"
- "\t\tobec = 'Liptakov'");
+ where = G_define_standard_option(G_OPT_WHERE);
select = G_define_option();
select->key = "select";
select->type = TYPE_STRING;
select->required = NO;
- select->description =
- _("Full select statement (only, if 'from_table' and 'where' is not used), e.g.:\n"
- "\t\tSELECT dedek FROM starobince WHERE obec = 'Frimburg'");
-
+ select->label = _("Full select statement (only, if 'from_table' and 'where' is not used)");
+ select->description = _("E.g.: SELECT dedek FROM starobince WHERE obec = 'Frimburg'");
+
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
Modified: grass/trunk/db/base/describe.c
===================================================================
--- grass/trunk/db/base/describe.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/db/base/describe.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -114,15 +114,15 @@
driver = G_define_standard_option(G_OPT_DRIVER);
driver->options = db_list_drivers();
if ((drv = db_get_default_driver_name()))
- driver->answer = drv;
+ driver->answer = (char *) drv;
database = G_define_standard_option(G_OPT_DATABASE);
if ((db = db_get_default_database_name()))
- database->answer = db;
+ database->answer = (char *) db;
/* Set description */
module = G_define_module();
- module->keywords = _("database, SQL");
+ module->keywords = _("database, attribute table");
module->description = _("Describes a table in detail.");
if (G_parser(argc, argv))
Modified: grass/trunk/db/base/drivers.c
===================================================================
--- grass/trunk/db/base/drivers.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/db/base/drivers.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -71,7 +71,7 @@
/* Set description */
module = G_define_module();
- module->keywords = _("database, SQL");
+ module->keywords = _("database, attribute table");
module->description = _("List all database drivers.");
if (G_parser(argc, argv))
Modified: grass/trunk/db/base/execute.c
===================================================================
--- grass/trunk/db/base/execute.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/db/base/execute.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -103,7 +103,7 @@
/* Set description */
module = G_define_module();
- module->keywords = _("database, SQL");
+ module->keywords = _("database, attribute table, SQL");
module->description = _("Executes any SQL statement.");
input = G_define_standard_option(G_OPT_F_INPUT);
@@ -113,11 +113,11 @@
driver = G_define_standard_option(G_OPT_DRIVER);
driver->options = db_list_drivers();
if ((drv = db_get_default_driver_name()))
- driver->answer = drv;
+ driver->answer = (char *) drv;
database = G_define_standard_option(G_OPT_DATABASE);
if ((db = db_get_default_database_name()))
- database->answer = db;
+ database->answer = (char *) db;
i = G_define_flag();
i->key = 'i';
Modified: grass/trunk/db/base/select.c
===================================================================
--- grass/trunk/db/base/select.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/db/base/select.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -176,12 +176,12 @@
database = G_define_standard_option(G_OPT_DATABASE);
if ((db = db_get_default_database_name()))
- database->answer = db;
+ database->answer = (char *) db;
driver = G_define_standard_option(G_OPT_DRIVER);
driver->options = db_list_drivers();
if ((drv = db_get_default_driver_name()))
- driver->answer = drv;
+ driver->answer = (char *) drv;
sql = G_define_option();
sql->key = "sql";
@@ -227,7 +227,7 @@
/* Set description */
module = G_define_module();
- module->keywords = _("database, SQL");
+ module->keywords = _("database, attribute table, SQL");
module->description = _("Selects data from table.");
if (G_parser(argc, argv))
Modified: grass/trunk/db/base/tables.c
===================================================================
--- grass/trunk/db/base/tables.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/db/base/tables.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -76,11 +76,11 @@
driver = G_define_standard_option(G_OPT_DRIVER);
driver->options = db_list_drivers();
if ((drv = db_get_default_driver_name()))
- driver->answer = drv;
+ driver->answer = (char *) drv;
database = G_define_standard_option(G_OPT_DATABASE);
if ((db = db_get_default_database_name()))
- database->answer = db;
+ database->answer = (char *) db;
p = G_define_flag();
p->key = 'p';
@@ -92,7 +92,7 @@
/* Set description */
module = G_define_module();
- module->keywords = _("database, SQL");
+ module->keywords = _("database, attribute table");
module->description = _("Lists all tables for a given database.");
if (G_parser(argc, argv))
Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py 2008-08-12 13:48:27 UTC (rev 32726)
@@ -192,16 +192,17 @@
if grassModule is not None:
xml.sax.parseString( getInterfaceDescription( grassModule ) , processTask( self ) )
- def get_param( self, aParam ):
- """
- Find and return a param by name.
- """
+ def get_param(self, aParam, raiseError=True):
+ """Find and return a param by name."""
for p in self.params:
lparam = len(aParam)
if p['name'] == aParam or \
p['name'][:lparam] == aParam:
return p
- raise ValueError, _("Parameter not found: %s") % aParam
+ if raiseError:
+ raise ValueError, _("Parameter not found: %s") % aParam
+ else:
+ return None
def set_param(self, aParam, aValue):
"""
@@ -1125,7 +1126,7 @@
which_sizer.Add(item=txt, proportion=0,
flag=wx.ADJUST_MINSIZE | wx.RIGHT | wx.LEFT | wx.TOP, border=5)
# element selection tree combobox (maps, icons, regions, etc.)
- if p.get('prompt','') not in ('color', 'dbcolumn') and \
+ if p.get('prompt','') not in ('color', 'dbcolumn', 'dbtable') and \
p.get('element', '') != 'file':
if p.get('multiple','no') == 'yes':
multiple = True
@@ -1148,17 +1149,24 @@
p['wxId'] = selection.GetChildren()[0].GetId()
selection.Bind(wx.EVT_TEXT, self.OnSetValue)
# dbcolumn entry
- elif p.get('prompt','') == 'dbcolumn':
+ elif p.get('prompt','') in ('dbcolumn', 'dbtable'):
+ if p.get('age', 'old') == 'old':
+ style = wx.CB_SIMPLE | wx.CB_READONLY
+ else:
+ style = wx.CB_SIMPLE
columns = wx.ComboBox(parent=which_panel, id=wx.ID_ANY,
size=globalvar.DIALOG_COMBOBOX_SIZE,
- style=wx.CB_SIMPLE | wx.CB_READONLY,
+ style=style,
choices=[])
p['wxId'] = columns.GetId()
p['wxGetValue'] = columns.GetStringSelection
- columns.Bind(wx.EVT_ENTER_WINDOW, self.OnDbColumn)
+ if p.get('prompt', '') == 'dbcolumn':
+ columns.Bind(wx.EVT_ENTER_WINDOW, self.OnDbColumn)
+ else:
+ columns.Bind(wx.EVT_ENTER_WINDOW, self.OnDbTable)
columns.Bind(wx.EVT_COMBOBOX, self.OnSetValue)
which_sizer.Add(item=columns, proportion=0,
- flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT, border=5)
+ flag=wx.ADJUST_MINSIZE | wx.BOTTOM | wx.LEFT, border=5)
# color entry
elif p.get('prompt','') == 'color':
# Heuristic way of finding whether transparent is allowed
@@ -1374,28 +1382,40 @@
def OnDbColumn(self, event):
"""Get list of table columns"""
choices = []
-
- mapName = utils.GetLayerNameFromCmd(self.task.getCmd(ignoreErrors=True))
- if mapName != _('<required>'):
- layer = 1
- for p in self.task.params:
- if p.get('name', '') == 'layer':
- value = p.get('value', '1')
- if value:
- layer = int(value)
- break
-
- cmd = ['v.info',
- 'map=%s' % mapName,
- 'layer=%d' % layer,
- '-c', '--q']
+ p = self.task.get_param('table', raiseError=False)
+ if p and p.get('prompt', '') == 'dbtable':
+ cmd = ['db.columns',
+ 'table=%s' % p.get('value')]
try:
- for line in gcmd.Command(cmd).ReadStdOutput():
- type, name = line.split('|')
- choices.append(name.strip())
+ choices = gcmd.Command(cmd).ReadStdOutput()
except gcmd.CmdError:
- pass
+ choices = []
+ if not p:
+ p = self.task.get_param('map', raiseError=False)
+ if not p:
+ p = self.task.get_param('input', raiseError=False)
+ if p:
+ mapName = utils.GetLayerNameFromCmd(self.task.getCmd(ignoreErrors=True))
+ if mapName != _('<required>'):
+ layer = 1
+ p = self.task.get_param('layer')
+ if p:
+ value = p.get('value', '1')
+ if value:
+ layer = int(value)
+
+ cmd = ['v.info',
+ 'map=%s' % mapName,
+ 'layer=%d' % layer,
+ '-c', '--q']
+
+ try:
+ for line in gcmd.Command(cmd).ReadStdOutput():
+ type, name = line.split('|')
+ choices.append(name.strip())
+ except gcmd.CmdError:
+ choices = []
win = self.FindWindowById(event.GetId())
@@ -1406,6 +1426,33 @@
event.Skip()
+ def OnDbTable(self, event):
+ """Get list of tables"""
+ # TODO: add driver/database
+ cmd = ['db.tables',
+ '-p', '--q']
+
+ for p in self.task.params:
+ if p.get('name', '') == 'driver' and \
+ len(p.get('value', '')) > 0:
+ cmd.append('driver=%s' % p.get('value'))
+ elif p.get('name', '') == 'database' and \
+ len(p.get('value', '')) > 0:
+ cmd.append('database=%s' % p.get('value'))
+
+ try:
+ choices = gcmd.Command(cmd).ReadStdOutput()
+ except gcmd.CmdError:
+ choices = []
+
+ win = self.FindWindowById(event.GetId())
+ win.SetItems(choices)
+
+ if len(choices) < 1:
+ win.SetValue('')
+
+ event.Skip()
+
def createCmd( self, ignoreErrors = False ):
"""
Produce a command line string (list) or feeding into GRASS.
Modified: grass/trunk/include/gis.h
===================================================================
--- grass/trunk/include/gis.h 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/include/gis.h 2008-08-12 13:48:27 UTC (rev 32726)
@@ -103,8 +103,9 @@
#define TYPE_STRING 3
#define YES 1
#define NO 0
-#define GISPROMPT_COLOR "color,grass,color"
-#define GISPROMPT_DBCOLUMN "dbcolumn,grass,dbcolumn"
+#define GISPROMPT_COLOR "old,color,color"
+#define GISPROMPT_DBCOLUMN "old,dbcolumn,dbcolumn"
+#define GISPROMPT_DBTABLE "old,dbtable,dbtable"
/* File/directory name lengths */
#define GNAME_MAX 256
Modified: grass/trunk/lib/gis/parser.c
===================================================================
--- grass/trunk/lib/gis/parser.c 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/lib/gis/parser.c 2008-08-12 13:48:27 UTC (rev 32726)
@@ -331,6 +331,7 @@
Opt->required = NO;
Opt->multiple = NO;
Opt->description = _("Table name");
+ Opt->gisprompt = GISPROMPT_DBTABLE;
break;
case G_OPT_DRIVER:
Opt->key = "driver";
Modified: grass/trunk/scripts/db.dropcol/db.dropcol
===================================================================
--- grass/trunk/scripts/db.dropcol/db.dropcol 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/scripts/db.dropcol/db.dropcol 2008-08-12 13:48:27 UTC (rev 32726)
@@ -32,6 +32,7 @@
#% key_desc : name
#% description: Table from which to drop attribute column
#% required : yes
+#% gisprompt: old,dbtable,dbtable
#%end
#%option
@@ -39,6 +40,7 @@
#% type: string
#% description: Name of the column
#% required : yes
+#% gisprompt: old,dbcolumn,dbcolumn
#%end
Modified: grass/trunk/scripts/db.droptable/db.droptable
===================================================================
--- grass/trunk/scripts/db.droptable/db.droptable 2008-08-12 13:35:20 UTC (rev 32725)
+++ grass/trunk/scripts/db.droptable/db.droptable 2008-08-12 13:48:27 UTC (rev 32726)
@@ -15,7 +15,7 @@
#%Module
-#% description: Drops an attribute table
+#% description: Drops an attribute table.
#% keywords: database, attribute table
#%End
@@ -30,6 +30,7 @@
#% key_desc : name
#% description: Table to drop
#% required : yes
+#% gisprompt: old,dbtable,dbtable
#%end
if [ -z "$GISBASE" ] ; then
More information about the grass-commit
mailing list