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 ### stolen from twisted.python.reflect and changed 35 ### the version in Twisted 1.3.0 checks length of backtrace as metric for 36 ### ImportError; for me this fails because two lines of ihooks.py are in 37 ### between 38 ### filed as http://www.twistedmatrix.com/users/roundup.twistd/twisted/issue698 39 ### remove this when fixed and depending on new upstream twisted41 """Get a fully named package, module, module-global object, or attribute. 42 """ 43 names = name.split('.') 44 topLevelPackage = None 45 moduleNames = names[:] 46 while not topLevelPackage: 47 try: 48 trialname = '.'.join(moduleNames) 49 topLevelPackage = __import__(trialname) 50 except ImportError: 51 import sys 52 # if the ImportError happened in the module being imported, 53 # this is a failure that should be handed to our caller. 54 shortname = trialname.split('.')[-1] 55 r = str(sys.exc_info()[1]) 56 if not (r.startswith('No module named') and 57 r.endswith(shortname)): 58 raise 59 60 #if str(sys.exc_info()[1]) != "No module named %s" % trialname: 61 # raise 62 moduleNames.pop() 63 64 obj = topLevelPackage 65 for n in names[1:]: 66 obj = getattr(obj, n) 67 68 return obj69
Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Apr 11 07:40:35 2008 | http://epydoc.sourceforge.net |