[GRASS-SVN] r53785 - grass/branches/releasebranch_6_4
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Nov 13 03:49:30 PST 2012
Author: martinl
Date: 2012-11-13 03:49:29 -0800 (Tue, 13 Nov 2012)
New Revision: 53785
Modified:
grass/branches/releasebranch_6_4/SUBMITTING_PYTHON
Log:
note Python pep08
Modified: grass/branches/releasebranch_6_4/SUBMITTING_PYTHON
===================================================================
--- grass/branches/releasebranch_6_4/SUBMITTING_PYTHON 2012-11-13 11:45:09 UTC (rev 53784)
+++ grass/branches/releasebranch_6_4/SUBMITTING_PYTHON 2012-11-13 11:49:29 UTC (rev 53785)
@@ -10,6 +10,8 @@
[ see SUBMITTING_SCRIPTS for shell script hints ]
[ see SUBMITTING_TCLTK for tcl and tk hints ]
+See also http://www.python.org/dev/peps/pep-0008/
+
0. Indentation
As Python determines nesting based upon indentation, it isn't just
@@ -20,10 +22,12 @@
See also "Python Style Guide" by Guido van Rossum
http://www.python.org/doc/essays/styleguide.html
+
1. Instructions for the GRASS script parser can be found in the g.parser
module's help page.
http://grass.osgeo.org/grass70/manuals/html70_user/g.parser.html
+
2. Use the directory structure to place your script appropriately into
the source tree
- scripts go into scripts/
@@ -31,6 +35,7 @@
Also add a Makefile and a <module>.html file into this directory.
See existing Python scripts for examples.
+
3. Add a header section to the script you submit and make sure you
include the copyright. The purpose section is meant to contain a
general over view of the code in the file to assist other
@@ -65,9 +70,11 @@
Just select an existing module which is close to your application to save
efforts.
+
4. We don't want the $ ID $ in source code any more as it causes problems
for the branches.
+
5. Create and use secure temporary files and directories. Use the
grass.tempfile() or grass.tempdir() functions to do this. e.g.
@@ -76,6 +83,7 @@
if TMP is None:
grass.fatal("Unable to create temporary files")
+
6. Use grass.findfile() when there is a need to test if a map exists.
# test for input raster map
@@ -112,6 +120,7 @@
Try to omit any usage of the 'print' command for informational output.
+
8. PLEASE take the time to add comments throughout your code explaining what
the code is doing. It will save a HUGE amount of time and frustration for
other programmers that may have to change your code in the future.
More information about the grass-commit
mailing list