Trees | Indices | Help |
---|
|
1 # -*- Mode: Python -*- 2 # vi:si:et:sw=4:sts=4:ts=4 3 # 4 # Flumotion - a streaming media server 5 # Copyright (C) 2004,2005,2006,2007 Fluendo, S.L. (www.fluendo.com). 6 # All rights reserved. 7 8 # This file may be distributed and/or modified under the terms of 9 # the GNU General Public License version 2 as published by 10 # the Free Software Foundation. 11 # This file is distributed without any warranty; without even the implied 12 # warranty of merchantability or fitness for a particular purpose. 13 # See "LICENSE.GPL" in the source distribution for more information. 14 15 # Licensees having purchased or holding a valid Flumotion Advanced 16 # Streaming Server license may use this file in accordance with the 17 # Flumotion Advanced Streaming Server Commercial License Agreement. 18 # See "LICENSE.Flumotion" in the source distribution for more information. 19 20 # Headers in this file shall remain intact. 21 22 """ 23 functions based on twisted.python.reflect 24 """ 25 26 # FIXME: clean up unused imports 27 from twisted.cred import checkers, credentials 28 from twisted.cred.portal import IRealm, Portal 29 from twisted.internet import protocol 30 from twisted.python import log, reflect 31 from twisted.spread import pb, flavors 32 from twisted.spread.pb import PBClientFactory 33 34 __version__ = "$Rev: 7162 $" 35 36 37 ### stolen from twisted.python.reflect and changed 38 ### the version in Twisted 1.3.0 checks length of backtrace as metric for 39 ### ImportError; for me this fails because two lines of ihooks.py are in 40 ### between 41 ### filed as http://www.twistedmatrix.com/users/roundup.twistd/twisted/issue698 42 ### remove this when fixed and depending on new upstream twisted 43 4446 """Get a fully named package, module, module-global object, or attribute. 47 """ 48 names = name.split('.') 49 topLevelPackage = None 50 moduleNames = names[:] 51 while not topLevelPackage: 52 try: 53 trialname = '.'.join(moduleNames) 54 topLevelPackage = __import__(trialname) 55 except ImportError: 56 import sys 57 # if the ImportError happened in the module being imported, 58 # this is a failure that should be handed to our caller. 59 shortname = trialname.split('.')[-1] 60 r = str(sys.exc_info()[1]) 61 if not (r.startswith('No module named') and 62 r.endswith(shortname)): 63 raise 64 65 #if str(sys.exc_info()[1]) != "No module named %s" % trialname: 66 # raise 67 moduleNames.pop() 68 69 obj = topLevelPackage 70 for n in names[1:]: 71 obj = getattr(obj, n) 72 73 return obj74
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Jan 27 19:57:52 2011 | http://epydoc.sourceforge.net |