[GRASS-SVN] r72467 - in grass-addons/grass7/imagery: . i.signature.remove
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 21 08:40:56 PDT 2018
Author: lucadelu
Date: 2018-03-21 08:40:56 -0700 (Wed, 21 Mar 2018)
New Revision: 72467
Added:
grass-addons/grass7/imagery/i.signature.remove/
grass-addons/grass7/imagery/i.signature.remove/Makefile
grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.html
grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.py
Log:
i.signature.remove: added modules to remove signature files
Added: grass-addons/grass7/imagery/i.signature.remove/Makefile
===================================================================
--- grass-addons/grass7/imagery/i.signature.remove/Makefile (rev 0)
+++ grass-addons/grass7/imagery/i.signature.remove/Makefile 2018-03-21 15:40:56 UTC (rev 72467)
@@ -0,0 +1,7 @@
+MODULE_TOPDIR = ../..
+
+PGM = i.signature.remove
+
+include $(MODULE_TOPDIR)/include/Make/Script.make
+
+default: script
Property changes on: grass-addons/grass7/imagery/i.signature.remove/Makefile
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-makefile
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.html
===================================================================
--- grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.html (rev 0)
+++ grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.html 2018-03-21 15:40:56 UTC (rev 72467)
@@ -0,0 +1,12 @@
+<H2>DESCRIPTION</H2>
+<em>i.signature.remove</em> remove one or more signature file from a group/subgroup
+
+<H2>EXAMPLE</H2>
+<div div="code"><pre>
+i.signature.remove igroup=name isubgroup=subname isignature=test
+</pre></div>
+
+
+<H2>AUTHOR</H2>
+
+Luca Delucchi
Property changes on: grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.html
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/html
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.py
===================================================================
--- grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.py (rev 0)
+++ grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.py 2018-03-21 15:40:56 UTC (rev 72467)
@@ -0,0 +1,95 @@
+#!/usr/bin/env python
+#
+############################################################################
+#
+# MODULE: i.signature.list
+# AUTHOR(S): Luca Delucchi
+#
+# PURPOSE: List signature file for a group/subgroup
+# COPYRIGHT: (C) 2018 by the GRASS Development Team
+#
+# This program is free software under the GNU General Public
+# License (>=v2). Read the file COPYING that comes with GRASS
+# for details.
+#
+#############################################################################
+
+#%module
+#% description: List signature file for a group/subgroup
+#% keyword: imagery
+#% keyword: list
+#% keyword: group
+#%end
+
+#%flag
+#% key: f
+#% description: Force removal (required for actual deletion of files)
+#%end
+
+#%option G_OPT_I_GROUP
+#% description: Group used to print signature file
+#% required : no
+#%end
+
+#%option G_OPT_I_SUBGROUP
+#% description: Subroup used to print signature file
+#% required : no
+#%end
+
+#%option
+#% key: signature
+#% type: string
+#% gisprompt: old,sig,sigfile
+#% label: Input signature file
+#% description: The name of the input signature file to copy
+#% multiple: yes
+#% required: yes
+#%end
+
+import os
+import sys
+import grass.script as grass
+
+def main():
+ group = options['group']
+ sub = options['subgroup']
+ signs = options['signature']
+ rem = flags['f']
+
+ gisenv = grass.gisenv()
+
+ try:
+ name, mapset = group.split('@', 1)
+ except ValueError:
+ name = group
+ mapset = gisenv['MAPSET']
+
+ output_str = "The following signature files would be deleted:\n"
+ for sign in signs.split(','):
+ path = os.path.join(gisenv['GISDBASE'], gisenv['LOCATION_NAME'])
+ path = os.path.join(path, mapset, 'group', name, 'subgroup', sub,
+ 'sig', sign)
+ if not os.path.exists(path):
+ grass.fatal(_("Signature file <{pa}> does not exist for group "
+ "<{gr}> and subgroup <{su}>".format(pa=sign,
+ gr=group,
+ su=sub)))
+ if rem:
+ try:
+ os.remove(path)
+ print(_("Removing signature file <{si}>".format(si=sign)))
+ except:
+ grass.warning(_("Signature file <{pa}> was not "
+ "removed".format(pa=sign)))
+ else:
+ output_str += "{gr}/{su}/{sig}\n".format(gr=group, su=sub,
+ sig=sign)
+
+ if not rem:
+ print(output_str.rstrip())
+ grass.warning(_("Nothing removed. You must use the force flag (-f) "
+ "to actually remove them. Exiting."))
+
+if __name__ == "__main__":
+ options, flags = grass.parser()
+ sys.exit(main())
Property changes on: grass-addons/grass7/imagery/i.signature.remove/i.signature.remove.py
___________________________________________________________________
Added: svn:mime-type
## -0,0 +1 ##
+text/x-python
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
More information about the grass-commit
mailing list