From b5819e34246a5abfd121be01d55ad93a0bd11a62 Mon Sep 17 00:00:00 2001 From: brushtyler Date: Mon, 7 Jun 2010 19:52:27 +0000 Subject: [PATCH] Removed the unnecessary setted paths git-svn-id: http://svn.osgeo.org/qgis/trunk@13682 c8812cc2-4d05-0410-92ff-de0c093fc19c --- python/plugins/GdalTools/GdalTools.py | 38 +++++++++++-------- python/plugins/GdalTools/tools/CMakeLists.txt | 2 + python/plugins/GdalTools/tools/__init__.py | 0 python/plugins/GdalTools/tools/doAbout.py | 12 ++++-- 4 files changed, 33 insertions(+), 19 deletions(-) create mode 100644 python/plugins/GdalTools/tools/__init__.py diff --git a/python/plugins/GdalTools/GdalTools.py b/python/plugins/GdalTools/GdalTools.py index c7a7a33f726..6784e9d9da9 100644 --- a/python/plugins/GdalTools/GdalTools.py +++ b/python/plugins/GdalTools/GdalTools.py @@ -25,25 +25,31 @@ from qgis.core import * # 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 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 ) -import GdalTools_utils as Utils class GdalTools: diff --git a/python/plugins/GdalTools/tools/CMakeLists.txt b/python/plugins/GdalTools/tools/CMakeLists.txt index 1a7f82715e3..66e1136c93b 100644 --- a/python/plugins/GdalTools/tools/CMakeLists.txt +++ b/python/plugins/GdalTools/tools/CMakeLists.txt @@ -1,3 +1,4 @@ +FILE(GLOB INIT_FILE __init__.py) FILE(GLOB PY_FILES *.py) FILE(GLOB UI_FILES *.ui) @@ -5,5 +6,6 @@ PYQT4_WRAP_UI(PYUI_FILES ${UI_FILES}) 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) diff --git a/python/plugins/GdalTools/tools/__init__.py b/python/plugins/GdalTools/tools/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/python/plugins/GdalTools/tools/doAbout.py b/python/plugins/GdalTools/tools/doAbout.py index 77f86c7b8b7..f7cd60b8b9b 100644 --- a/python/plugins/GdalTools/tools/doAbout.py +++ b/python/plugins/GdalTools/tools/doAbout.py @@ -6,13 +6,19 @@ from qgis.core import * 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):