[GRASS-SVN] r71004 - grass-addons/grass7/raster/r.denoise

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 2 18:47:05 PDT 2017


Author: wenzeslaus
Date: 2017-05-02 18:47:05 -0700 (Tue, 02 May 2017)
New Revision: 71004

Modified:
   grass-addons/grass7/raster/r.denoise/r.denoise.py
Log:
r.denoise: lazy import pyproj

Modified: grass-addons/grass7/raster/r.denoise/r.denoise.py
===================================================================
--- grass-addons/grass7/raster/r.denoise/r.denoise.py	2017-05-02 22:34:41 UTC (rev 71003)
+++ grass-addons/grass7/raster/r.denoise/r.denoise.py	2017-05-03 01:47:05 UTC (rev 71004)
@@ -73,11 +73,7 @@
 from itertools import izip
 import grass.script as grass
 
-# pyproj
-try:
-    import pyproj
-except ImportError:
-    grass.fatal(_("pyproj not found, install it first: pip install pyproj (https://jswhit.github.io/pyproj)"))
+# pyproj lazy imported at the end of the file
 
 # PID for temporary files
 unique = str(os.getpid()) 
@@ -219,6 +215,17 @@
 #run the module
 if __name__ == "__main__":
     options, flags = grass.parser()
+
+    # lazy import
+    # TODO: ideally, it should be done only if reprojection is needed
+    # or replace by pure GRASS GIS if pyproj not available
+    try:
+        import pyproj
+    except ImportError:
+        grass.fatal(_("pyproj not found, install it first, e.g.:"
+                      " pip install pyproj"
+                      " (https://jswhit.github.io/pyproj)"))
+
     atexit.register(cleanup)
     check_requirements()
     main()



More information about the grass-commit mailing list