Sfoglia il codice sorgente

t.upgrade: added from addons (#1438)

* t.upgrade: added from addons
- copied from https://github.com/OSGeo/grass-addons/tree/master/grass7/temporal/t.upgrade
* Windows: fix t.upgrade call
* change grass.temporal to lazy import
* remove UTF-8 coding line
* black: blank line after import
* revert CI related changes
* module description fixed
* Year pedantry
* import grass.script as gs
* no need for sys.exit()
* global variables options and flags are not used

Co-authored-by: Vaclav Petras <wenzeslaus@gmail.com>
Co-authored-by: Martin Landa <landa.martin@gmail.com>
Markus Neteler 4 anni fa
parent
commit
98347de41f

+ 1 - 0
temporal/Makefile

@@ -41,6 +41,7 @@ SUBDIRS = \
 	t.select \
 	t.snap \
 	t.shift \
+	t.upgrade \
 	t.vect.list \
 	t.vect.db.select \
 	t.vect.export \

+ 7 - 0
temporal/t.upgrade/Makefile

@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../../
+
+PGM = t.upgrade
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script $(TEST_DST)

+ 26 - 0
temporal/t.upgrade/t.upgrade.html

@@ -0,0 +1,26 @@
+<h2>DESCRIPTION</h2>
+
+This module upgrades the temporal database in the current mapset
+from version 2 (default in GRASS 7) to 3 (default in GRASS 8).
+The version 3 introduces a band reference support, see
+<em><a href="g.bands.html">g.bands</a></em> for details.
+
+<h2>EXAMPLE</h2>
+
+<div class="code"><pre>
+t.upgrade
+</pre></div>
+
+<h2>SEE ALSO</h2>
+
+<em>
+<a href="t.info.html">t.info</a>
+</em>
+
+<h2>AUTHORS</h2>
+
+Martin Landa and Markus Neteler
+
+<!--
+<p><i>Last changed: $Date$</i>
+-->

+ 46 - 0
temporal/t.upgrade/t.upgrade.py

@@ -0,0 +1,46 @@
+#!/usr/bin/env python3
+############################################################################
+#
+# MODULE:       t.upgrade
+# AUTHOR(S):    Martin Landa, Markus Neteler
+#
+# PURPOSE:      Upgrade of TGRASS DB
+# COPYRIGHT:    (C) 2020-2021 by Martin Landa, and the GRASS Development Team
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#############################################################################
+
+# %module
+# % description: Upgrades the version of the temporal database.
+# % keyword: temporal
+# % keyword: metadata
+# % keyword: time
+# %end
+
+import grass.script as gs
+
+
+def main():
+    # lazy imports
+    import grass.temporal as tgis
+
+    tgis.init(skip_db_version_check=True)
+
+    dbif = tgis.SQLDatabaseInterfaceConnection()
+    dbif.connect()
+
+    tgis.upgrade_temporal_database(dbif)
+
+
+if __name__ == "__main__":
+    gs.parser()
+    main()