[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r9395 - trunk/gnue-common/src/utils
From: |
jcater |
Subject: |
[gnue] r9395 - trunk/gnue-common/src/utils |
Date: |
Wed, 21 Feb 2007 19:38:13 -0600 (CST) |
Author: jcater
Date: 2007-02-21 19:38:13 -0600 (Wed, 21 Feb 2007)
New Revision: 9395
Modified:
trunk/gnue-common/src/utils/FileUtils.py
Log:
make dyn_import give a more useful error message when a module can't be
imported; updated some old python-isms
Modified: trunk/gnue-common/src/utils/FileUtils.py
===================================================================
--- trunk/gnue-common/src/utils/FileUtils.py 2007-02-21 19:35:10 UTC (rev
9394)
+++ trunk/gnue-common/src/utils/FileUtils.py 2007-02-22 01:38:13 UTC (rev
9395)
@@ -35,17 +35,15 @@
#
# Dynamically import a python module
#
-import string
-
def dyn_import(name):
try:
mod = __import__(name)
- components = string.split(name, '.')
+ components = '.'.split(name)
for comp in components[1:]:
mod = getattr(mod, comp)
return mod
- except (AttributeError,ValueError), mesg:
- raise ImportError, mesg
+ except (AttributeError,ValueError, ImportError), mesg:
+ raise ImportError, 'Unable to import %s: %s' % (name, mesg)
############################################################
@@ -101,13 +99,11 @@
# fix for a bug in URLPARSE
if host=="":
# path="//host/path" -> path=path host=host
- pathlist=string.split(path[2:],"/",1)
- host=pathlist[0]
- path=pathlist[1]
+ host, path ="/".split(path[2:],1)
# check if host ends in ".gear"
if host[-5:]!=".gear":
- host=host+".gear"
+ host += ".gear"
# 1. search for gear in the local directory
try:
@@ -138,7 +134,7 @@
# convert a single filename to a full gear url
- if resource[:5]!="gear:":
+ if resource[:5] != "gear:":
resource="gear://"+urllib.quote(resource,"")+"/"
gear._gearFileRes=resource
@@ -147,7 +143,7 @@
from gnue.common.gear.NavigationBuilder import buildNavigatorFile
- navi=buildNavigatorFile(filelist,host,1)
+ navi = buildNavigatorFile(filelist,host,1)
return cStringIO.StringIO(navi)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r9395 - trunk/gnue-common/src/utils,
jcater <=