[QGIS Commit] r13682 - in trunk/qgis/python/plugins/GdalTools: . tools

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Jun 7 15:52:29 EDT 2010


Author: brushtyler
Date: 2010-06-07 15:52:27 -0400 (Mon, 07 Jun 2010)
New Revision: 13682

Added:
   trunk/qgis/python/plugins/GdalTools/tools/__init__.py
Modified:
   trunk/qgis/python/plugins/GdalTools/GdalTools.py
   trunk/qgis/python/plugins/GdalTools/tools/CMakeLists.txt
   trunk/qgis/python/plugins/GdalTools/tools/doAbout.py
Log:
Removed the unnecessary setted paths


Modified: trunk/qgis/python/plugins/GdalTools/GdalTools.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/GdalTools.py	2010-06-07 17:12:41 UTC (rev 13681)
+++ trunk/qgis/python/plugins/GdalTools/GdalTools.py	2010-06-07 19:52:27 UTC (rev 13682)
@@ -25,26 +25,32 @@
 # Initialize Qt resources from file resources_rc.py
 import resources_rc
 
-# Import required modules and if missing show the right name of them
+# Import required modules and if missing show the right module's name
 req_mods = { "osgeo": "osgeo [python-gdal]" }
-for k, v in req_mods.iteritems():
-  try:
-    exec( "import %s" % k )
-  except ImportError, e:
-    errorStr = str(e)
-    if len(v) > 0:
-      errorStr = errorStr.replace( k, v ) 
-    raise ImportError( errorStr )
 
-# Set up current path, so that we know where to look for modules
-import os.path, sys
-currentPath = os.path.dirname( __file__ )
-sys.path.append( os.path.abspath(os.path.dirname( __file__ ) + '/tools' ) )
-import doBuildVRT, doContour, doRasterize, doPolygonize, doMerge, doSieve, doProximity, doNearBlack, doWarp, doGrid, doTranslate, doClipper
-import doInfo, doProjection, doOverview, doRgbPct, doPctRgb, doSettings, doAbout
+try:
+  # Set up current path, so that we know where to look for modules
+  import os.path, sys
+  currentPath = os.path.dirname( __file__ )
+  modulesPath = os.path.abspath( currentPath + '/tools' )
+  sys.path.append( modulesPath )
 
-import GdalTools_utils as Utils
+  import GdalTools_utils as Utils
 
+  import doBuildVRT, doContour, doRasterize, doPolygonize, doMerge, doSieve, doProximity, doNearBlack
+  import doWarp, doGrid, doTranslate, doClipper, doInfo, doProjection, doOverview, doRgbPct, doPctRgb
+  import doSettings, doAbout
+
+  sys.path.remove( modulesPath )
+
+except ImportError, e:
+  error_str = str(e)
+  error_mod = error_str.replace( "No module named ", "" )
+  if req_mods.has_key( error_mod ):
+    error_str = error_str.replace( error_mod, req_mods[error_mod] )
+  raise ImportError( error_str )
+
+
 class GdalTools:
 
   def __init__( self, iface ):

Modified: trunk/qgis/python/plugins/GdalTools/tools/CMakeLists.txt
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/CMakeLists.txt	2010-06-07 17:12:41 UTC (rev 13681)
+++ trunk/qgis/python/plugins/GdalTools/tools/CMakeLists.txt	2010-06-07 19:52:27 UTC (rev 13682)
@@ -1,3 +1,4 @@
+FILE(GLOB INIT_FILE __init__.py)
 FILE(GLOB PY_FILES *.py)
 FILE(GLOB UI_FILES *.ui)
 
@@ -5,5 +6,6 @@
 
 ADD_CUSTOM_TARGET(gdaltools_tools ALL DEPENDS ${PYUI_FILES})
 
+INSTALL(FILES ${INIT_FILE} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools/tools)
 INSTALL(FILES ${PY_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools/tools)
 INSTALL(FILES ${PYUI_FILES} DESTINATION ${QGIS_DATA_DIR}/python/plugins/GdalTools/tools)

Modified: trunk/qgis/python/plugins/GdalTools/tools/doAbout.py
===================================================================
--- trunk/qgis/python/plugins/GdalTools/tools/doAbout.py	2010-06-07 17:12:41 UTC (rev 13681)
+++ trunk/qgis/python/plugins/GdalTools/tools/doAbout.py	2010-06-07 19:52:27 UTC (rev 13682)
@@ -6,13 +6,19 @@
 from qgis.gui import *
 
 from ui_dialogAbout import Ui_GdalToolsAboutDialog as Ui_Dialog
+
+# Set up current path, so that we know where to look for version
 import os.path, sys
-# Set up current path, so that we know where to look for init file
 currentPath = os.path.dirname( __file__ )
-sys.path.append( os.path.abspath(os.path.dirname( __file__ )[:-6] ) )
-# prepended the dir, to avoid conflicts with other __init__ modules in search path
+pluginPath = os.path.abspath( currentPath + "/.." )
+sys.path.append( pluginPath )
+
+# prepended the module name, to avoid conflicts with other __init__ modules in search path
 from GdalTools.__init__ import version
 
+sys.path.remove( pluginPath )
+
+
 class GdalToolsAboutDialog(QDialog, Ui_Dialog):
 
   def __init__(self, iface):



More information about the QGIS-commit mailing list