[GRASS-SVN] r55861 - in grass/trunk: lib/python/temporal temporal/t.rename temporal/t.support temporal/t.unregister
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Apr 17 14:57:06 PDT 2013
Author: huhabla
Date: 2013-04-17 14:57:05 -0700 (Wed, 17 Apr 2013)
New Revision: 55861
Modified:
grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
grass/trunk/lib/python/temporal/base.py
grass/trunk/lib/python/temporal/metadata.py
grass/trunk/lib/python/temporal/space_time_datasets_tools.py
grass/trunk/temporal/t.rename/t.rename.py
grass/trunk/temporal/t.support/t.support.py
grass/trunk/temporal/t.unregister/t.unregister.py
Log:
Implemented command history support for several commands that modify space time datasets.
Modified: grass/trunk/lib/python/temporal/abstract_space_time_dataset.py
===================================================================
--- grass/trunk/lib/python/temporal/abstract_space_time_dataset.py 2013-04-17 21:56:11 UTC (rev 55860)
+++ grass/trunk/lib/python/temporal/abstract_space_time_dataset.py 2013-04-17 21:57:05 UTC (rev 55861)
@@ -143,6 +143,19 @@
self.metadata.set_title(title)
self.metadata.set_description(description)
self.metadata.set_command(self.create_command_string())
+
+ def update_command_string(self, dbif=None):
+ """!Append the current command string to any existing command string
+ in the metadata class and calls metadata update
+ """
+
+ self.metadata.select(dbif=dbif)
+ command = self.metadata.get_command()
+ if command is None:
+ command = ""
+ command += self.create_command_string()
+ self.metadata.set_command(command)
+ self.metadata.update(dbif=dbif)
def create_command_string(self):
"""!Create the command string that was used to create this
@@ -166,10 +179,12 @@
# Check for sub strings
if token.find("=") > 0:
first = token.split("=")[0]
- second = token.split("=")[1]
+ second = ""
- if second.find(" ") >= 0:
- token = "%s=\"%s\""%(first, second)
+ for t in token.split("=")[1:]:
+ second += t
+
+ token = "%s=\"%s\""%(first, second)
if length + len(token) >= 76:
command += "\n %s"%(token)
@@ -178,6 +193,7 @@
command += " %s"%(token)
length += len(token) + 1
+ command += "\n"
return command
def get_semantic_type(self):
Modified: grass/trunk/lib/python/temporal/base.py
===================================================================
--- grass/trunk/lib/python/temporal/base.py 2013-04-17 21:56:11 UTC (rev 55860)
+++ grass/trunk/lib/python/temporal/base.py 2013-04-17 21:57:05 UTC (rev 55861)
@@ -442,7 +442,7 @@
if self.ident is None:
raise IOError("Missing identifer")
- sql, args = self.get_update_statement(indent)
+ sql, args = self.get_update_statement(ident)
#print sql
#print args
Modified: grass/trunk/lib/python/temporal/metadata.py
===================================================================
--- grass/trunk/lib/python/temporal/metadata.py 2013-04-17 21:56:11 UTC (rev 55860)
+++ grass/trunk/lib/python/temporal/metadata.py 2013-04-17 21:57:05 UTC (rev 55861)
@@ -892,7 +892,7 @@
| Soils
| Description:
| Soils 1950 - 2010
- | Command of creation:
+ | Commands of creation:
>>> meta.print_shell_info()
number_of_maps=None
@@ -983,7 +983,7 @@
print " | " + str(self.get_title())
print " | Description:"
print " | " + str(self.get_description())
- print " | Command of creation:"
+ print " | Commands of creation:"
command = self.get_command()
if command:
for token in command.split("\n"):
@@ -1032,7 +1032,7 @@
| Soils
| Description:
| Soils 1950 - 2010
- | Command of creation:
+ | Commands of creation:
| North-South resolution min:. None
| North-South resolution max:. None
| East-west resolution min:... None
@@ -1226,7 +1226,7 @@
| Soils
| Description:
| Soils 1950 - 2010
- | Command of creation:
+ | Commands of creation:
| North-South resolution min:. None
| North-South resolution max:. None
| East-west resolution min:... None
@@ -1331,7 +1331,7 @@
| Soils
| Description:
| Soils 1950 - 2010
- | Command of creation:
+ | Commands of creation:
| North-South resolution min:. None
| North-South resolution max:. None
| East-west resolution min:... None
@@ -1469,7 +1469,7 @@
| LIDARS
| Description:
| LIDARS 2008 - 2010
- | Command of creation:
+ | Commands of creation:
| Vector register table:...... None
| Number of points ........... None
| Number of lines ............ None
Modified: grass/trunk/lib/python/temporal/space_time_datasets_tools.py
===================================================================
--- grass/trunk/lib/python/temporal/space_time_datasets_tools.py 2013-04-17 21:56:11 UTC (rev 55860)
+++ grass/trunk/lib/python/temporal/space_time_datasets_tools.py 2013-04-17 21:57:05 UTC (rev 55861)
@@ -314,6 +314,8 @@
core.message(_("Update space time raster dataset"))
sp.update_from_registered_maps(dbif)
+ sp.update_command_string(dbif=dbif)
+
# Update affected datasets
if datatsets_to_modify:
for dataset in datatsets_to_modify:
Modified: grass/trunk/temporal/t.rename/t.rename.py
===================================================================
--- grass/trunk/temporal/t.rename/t.rename.py 2013-04-17 21:56:11 UTC (rev 55860)
+++ grass/trunk/temporal/t.rename/t.rename.py 2013-04-17 21:57:05 UTC (rev 55861)
@@ -96,6 +96,7 @@
stds.select(dbif=dbif)
stds.rename(ident=new_id, dbif=dbif)
+ stds.update_command_string(dbif=dbif)
if __name__ == "__main__":
options, flags = grass.parser()
Modified: grass/trunk/temporal/t.support/t.support.py
===================================================================
--- grass/trunk/temporal/t.support/t.support.py 2013-04-17 21:56:11 UTC (rev 55860)
+++ grass/trunk/temporal/t.support/t.support.py 2013-04-17 21:57:05 UTC (rev 55861)
@@ -163,6 +163,8 @@
if map_update or update:
stds.update_from_registered_maps(dbif=dbif)
+
+ stds.update_command_string(dbif=dbif)
dbif.close()
Modified: grass/trunk/temporal/t.unregister/t.unregister.py
===================================================================
--- grass/trunk/temporal/t.unregister/t.unregister.py 2013-04-17 21:56:11 UTC (rev 55860)
+++ grass/trunk/temporal/t.unregister/t.unregister.py 2013-04-17 21:57:05 UTC (rev 55861)
@@ -171,6 +171,7 @@
grass.message(_("Unregistered maps from space time dataset(s)"))
if name:
sp.update_from_registered_maps(dbif)
+ sp.update_command_string(dbif=dbif)
elif len(update_dict) > 0:
count = 0
for key in update_dict.keys():
More information about the grass-commit
mailing list