Quellcode durchsuchen

pythonlib: use non-py extension for tmp file (https://trac.osgeo.org/grass/changeset/65345) to avoid picking of the file by autodoc, fix syntax in https://trac.osgeo.org/grass/changeset/65346

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@65429 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras vor 10 Jahren
Ursprung
Commit
347b3490eb
2 geänderte Dateien mit 11 neuen und 8 gelöschten Zeilen
  1. 3 3
      lib/python/script/Makefile
  2. 8 5
      lib/python/script/setup.py

+ 3 - 3
lib/python/script/Makefile

@@ -18,12 +18,12 @@ $(DSTDIR):
 $(DSTDIR)/%: % | $(DSTDIR)
 	$(INSTALL_DATA) $< $@
 
-EXTRA_CLEAN_FILES = setup.tmp.py
+EXTRA_CLEAN_FILES = setup.py.tmp
 
-$(DSTDIR)/setup.py: setup.tmp.py | $(DSTDIR)
+$(DSTDIR)/setup.py: setup.py.tmp | $(DSTDIR)
 	$(INSTALL_DATA) $< $@
 
-setup.tmp.py: setup.py
+setup.py.tmp: setup.py
 	sed \
 	-e 's#@LD_LIBRARY_PATH_VAR@#$(LD_LIBRARY_PATH_VAR)#' \
 	$< > $@

+ 8 - 5
lib/python/script/setup.py

@@ -47,9 +47,9 @@ Usage::
                  " {cmd}: {error}".format(cmd=startcmd[0], error=error))
     if p.returncode != 0:
         sys.exit("ERROR: Issues running GRASS GIS start script"
-                 " {cmd}:\n{error}"
+                 " {cmd}: {error}"
                  .format(cmd=' '.join(startcmd), error=err))
-    gisbase = out.strip('\n\r')
+    gisbase = out.strip(os.linesep)
 
     # set GISBASE environment variable
     os.environ['GISBASE'] = gisbase
@@ -109,6 +109,8 @@ def write_gisrc(dbase, location, mapset):
     return gisrc
 
 
+# TODO: there should be a function to do the clean up
+# (unset the GISRC and delete the file)
 def init(gisbase, dbase='', location='demolocation', mapset='PERMANENT'):
     """Initialize system variables to run GRASS modules
 
@@ -126,12 +128,13 @@ def init(gisbase, dbase='', location='demolocation', mapset='PERMANENT'):
 
     Basic usage::
 
-        # ... setup GISBASE and PYTHON path
-        grass.script as gscript
+        # ... setup GISBASE and PYTHON path before import
+        import grass.script as gscript
         gisrc = gscript.setup.init("/usr/lib/grass64",
                                    "/home/john/grassdata",
                                    "nc_spm_08", "user1")
-        # ... use GRASS modules
+        # ... use GRASS modules here
+        # remove the session's gisrc file to end the session
         os.remove(gisrc)
 
     :param gisbase: path to GRASS installation