[GRASS-SVN] r41763 - grass/branches/releasebranch_6_4/lib/python
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Apr 8 15:59:22 EDT 2010
Author: neteler
Date: 2010-04-08 15:59:21 -0400 (Thu, 08 Apr 2010)
New Revision: 41763
Modified:
grass/branches/releasebranch_6_4/lib/python/core.py
Log:
backport docs
Modified: grass/branches/releasebranch_6_4/lib/python/core.py
===================================================================
--- grass/branches/releasebranch_6_4/lib/python/core.py 2010-04-08 19:57:53 UTC (rev 41762)
+++ grass/branches/releasebranch_6_4/lib/python/core.py 2010-04-08 19:59:21 UTC (rev 41763)
@@ -20,6 +20,7 @@
@author Glynn Clements
@author Martin Landa <landa.martin gmail.com>
+ at author Michael Barton <michael.barton at asu.edu>
"""
import os
@@ -148,6 +149,11 @@
"""!Passes all arguments to start_command, then waits for the process to
complete, returning its exit code. Similar to subprocess.call(), but
with the make_command() interface.
+
+ @param args
+ @param kwargs
+
+ @return exit code
"""
ps = start_command(*args, **kwargs)
return ps.wait()
@@ -180,6 +186,11 @@
def feed_command(*args, **kwargs):
"""!Passes all arguments to start_command, but also adds
"stdin = PIPE". Returns the Popen object.
+
+ @param args
+ @param kwargs
+
+ @return Popen object
"""
kwargs['stdin'] = PIPE
return start_command(*args, **kwargs)
@@ -187,6 +198,11 @@
def read_command(*args, **kwargs):
"""!Passes all arguments to pipe_command, then waits for the process to
complete, returning its stdout (i.e. similar to shell `backticks`).
+
+ @param args
+ @param kwargs
+
+ @return stdout
"""
ps = pipe_command(*args, **kwargs)
return ps.communicate()[0]
@@ -201,6 +217,11 @@
@code
parse_command(..., parse = (grass.parse_key_val, { 'sep' : ':' }))
@endcode
+
+ @param args
+ @param kwargs
+
+ @return parsed module output
"""
parse = None
if kwargs.has_key('parse'):
@@ -220,6 +241,11 @@
def write_command(*args, **kwargs):
"""!Passes all arguments to feed_command, with the string specified
by the 'stdin' argument fed to the process' stdin.
+
+ @param args
+ @param kwargs
+
+ @return return code
"""
stdin = kwargs['stdin']
p = feed_command(*args, **kwargs)
@@ -258,7 +284,7 @@
def debug(msg, debug = 1):
"""!Display a debugging message using g.message -d
- @param msg message to be displayed
+ @param msg debugging message to be displayed
@param debug debug level (0-5)
@return g.message's exit code
@@ -268,7 +294,7 @@
def verbose(msg):
"""!Display a verbose message using g.message -v
- @param msg message to be displayed
+ @param msg verbose message to be displayed
@return g.message's exit code
"""
@@ -277,7 +303,7 @@
def info(msg):
"""!Display an informational message using g.message -i
- @param msg message to be displayed
+ @param msg informational message to be displayed
@return g.message's exit code
"""
@@ -286,7 +312,7 @@
def warning(msg):
"""!Display a warning message using g.message -w
- @param msg message to be displayed
+ @param msg warning message to be displayed
@return g.message's exit code
"""
@@ -295,7 +321,7 @@
def error(msg):
"""!Display an error message using g.message -e
- @param msg message to be displayed
+ @param msg error message to be displayed
@return g.message's exit code
"""
@@ -304,7 +330,7 @@
def fatal(msg):
"""!Display an error message using g.message -e, then abort
- @param msg message to be displayed
+ @param msg error message to be displayed
@return g.message's exit code
"""
@@ -328,9 +354,11 @@
def parser():
"""!Interface to g.parser, intended to be run from the top-level, e.g.:
+ @code
if __name__ == "__main__":
options, flags = grass.parser()
main()
+ @endcode
Thereafter, the global variables "options" and "flags" will be
dictionaries containing option/flag values, keyed by lower-case
@@ -373,6 +401,14 @@
def parse_key_val(s, sep = '=', dflt = None, val_type = None, vsep = None):
"""!Parse a string into a dictionary, where entries are separated
by newlines and the key and value are separated by `sep' (default: `=')
+
+ @param s string to be parsed
+ @param sep key/value separator
+ @param dflt default value to be used
+ @param val_type value type (None for no cast)
+ @param vsep vertical separator (default os.linesep)
+
+ @return parsed input (dictionary of keys/values)
"""
result = {}
@@ -512,6 +548,9 @@
def mlist_grouped(type, mapset = None, pattern = None):
"""!Returns the output from running g.mlist, as a dictionary where the keys
are mapset names and the values are lists of maps in that mapset.
+
+ @param type element type
+ @param mapset mapset name (default all mapset in search path)
@param pattern pattern string
"""
result = {}
@@ -603,7 +642,7 @@
@param val color value
@param dflt default color value
-
+
@return tuple RGB
"""
if val in named_colors:
@@ -639,6 +678,9 @@
def basename(path, ext = None):
"""!Remove leading directory components and an optional extension
from the specified path
+
+ @param path path
+ @param ext extension
"""
name = os.path.basename(path)
if not ext:
@@ -653,6 +695,9 @@
def find_program(pgm, args = []):
"""!Attempt to run a program, with optional arguments. Return False
if the attempt failed due to a missing executable, True otherwise
+
+ @param pgm program name
+ @param args list of arguments
"""
nuldev = file(os.devnull, 'w+')
try:
@@ -668,6 +713,8 @@
def try_remove(path):
"""!Attempt to remove a file; no exception is generated if the
attempt fails.
+
+ @param path path
"""
try:
os.remove(path)
@@ -679,6 +726,8 @@
def try_rmdir(path):
"""!Attempt to remove a directory; no exception is generated if the
attempt fails.
+
+ @param path path
"""
try:
os.rmdir(path)
More information about the grass-commit
mailing list