Explorar o código

core.py: backport grass.separator() implementation (trunk https://trac.osgeo.org/grass/changeset/60622 and related)

git-svn-id: https://svn.osgeo.org/grass/grass/branches/releasebranch_7_0@60630 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Neteler %!s(int64=11) %!d(string=hai) anos
pai
achega
0f68b3e04e
Modificáronse 1 ficheiros con 22 adicións e 0 borrados
  1. 22 0
      lib/python/script/core.py

+ 22 - 0
lib/python/script/core.py

@@ -674,6 +674,28 @@ def parser():
 
     return _parse_opts(lines[1:])
 
+
+def separator(sep):
+    """!Returns separator from G_OPT_F_SEP appropriately converted
+    to character.
+
+    @param separator character or separator keyword
+
+    @return separator character
+    """
+    if sep == "pipe":
+        return "|"
+    elif sep == "comma":
+        return ","
+    elif sep == "space":
+        return " "
+    elif sep == "tab" or sep == "\\t":
+        return "\t"
+    elif sep == "newline" or sep == "\\n":
+        return "\n"
+    return sep
+    
+
 # interface to g.tempfile