Changeset 13168
- Timestamp:
- 03/13/2005 05:15:41 AM (4 years ago)
- Files:
-
-
trunk/admin/release-twisted (modified) (7 diffs)
-
trunk/setup.py (modified) (1 diff)
-
trunk/twisted/lore/scripts/lore.py (modified) (4 diffs)
-
trunk/twisted/plugin.py (copied) (copied from branches/exarkun/newplugins/twisted/plugin.py)
-
trunk/twisted/plugins (copied) (copied from branches/exarkun/newplugins/twisted/plugins)
-
trunk/twisted/plugins.tml (deleted)
-
trunk/twisted/python/dist.py (modified) (1 diff)
-
trunk/twisted/python/plugin.py (modified) (14 diffs)
-
trunk/twisted/scripts/mktap.py (modified) (5 diffs)
-
trunk/twisted/scripts/trial.py (modified) (2 diffs)
-
trunk/twisted/test/test_plugin.py (copied) (copied from branches/exarkun/newplugins/twisted/test/test_plugin.py)
-
trunk/twisted/topfiles/setup.py (modified) (1 diff)
-
trunk/twisted/words/botbot.py (modified) (3 diffs)
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
-
trunk/admin/release-twisted
r13134 r13168 123 123 sh('tar cjhf %(tdir)s.tar.bz2 %(tdir)s' % locals()) 124 124 125 126 125 127 126 ## … … 138 137 sh('svn export %s Twisted.exp' % (opts['temptagurl'],)) 139 138 140 139 141 140 def makeDocCore(opts): 142 141 ver = opts['core-version'] … … 195 194 os.makedirs(os.path.join(tdir, 'twisted')) 196 195 os.makedirs(os.path.join(tdir, 'bin')) 197 196 198 197 twisted_subprojects = ','.join(dist.twisted_subprojects) 199 198 … … 234 233 zig = glob.glob('ZopeInterface-*.tgz') 235 234 if not zig: 236 raise Exception("Please download ZopeInterface from " 237 "http://www.zope.org/Products/ZopeInterface") 235 raise Exception( 236 "Creating sumo distribution rquires a ZopeInterface tarball - " 237 "Please download one from <http://www.zope.org/Products/ZopeInterface>.") 238 238 zi = zig[0] 239 239 os.makedirs(tdir) … … 258 258 % subproj) 259 259 sumoReplace['%s-SVN-Trunk' % subproj.capitalize()] = subver 260 260 261 261 replaceInFile(os.path.join(tdir, 'README'), sumoReplace) 262 262 # replace versions for core … … 276 276 sdir = 'Twisted%s-%s' % (proj.capitalize(), version) 277 277 os.makedirs(sdir+'/twisted/%s' % (proj,)) 278 os.makedirs(sdir+'/twisted/plugins') 279 278 280 sh(''' 279 281 ln -s `pwd`/Twisted.exp/twisted/%(proj)s/* %(sdir)s/twisted/%(proj)s … … 283 285 ln -s `pwd`/Twisted.exp/LICENSE %(sdir)s 284 286 ln -s `pwd`/Twisted.exp/twisted/%(proj)s/topfiles/* %(sdir)s 287 288 # We want this project's plugin module 289 ln -s `pwd`/Twisted.exp/twisted/plugins/twisted_%(proj)s.py %(sdir)s/twisted/plugins 285 290 286 291 # we want copies so we can replace versions -
trunk/setup.py
r13158 r13168 43 43 44 44 result = os.spawnv(os.P_WAIT, sys.executable, 45 [sys.executable, setupPy] + args)45 [sys.executable, setupPy] + args) 46 46 if result != 0: 47 47 sys.stderr.write("Error: Subprocess exited with result %d for project %s\n" % -
trunk/twisted/lore/scripts/lore.py
r11450 r13168 3 3 4 4 import sys 5 6 from zope.interface import Interface, Attribute 7 5 8 from twisted.lore import process, default, indexer, numberer, htmlbook 6 from twisted.python import usage, plugin, reflect 9 10 from twisted.python import usage, plugin as oldplugin, reflect 11 from twisted import plugin as newplugin 12 13 class IProcessor(Interface): 14 """ 15 """ 16 17 factory = Attribute( 18 "") 7 19 8 20 class Options(usage.Options): … … 40 52 41 53 def getProcessor(input, output, config): 42 plugins = plugin.getPlugIns("lore", None, None)54 plugins = oldplugin._getPlugIns("lore") 43 55 for plug in plugins: 44 56 if plug.tapname == input: … … 46 58 break 47 59 else: 48 # try treating it as a module name 49 try: 50 module = reflect.namedModule(input) 51 except ImportError: 52 print '%s: no such input: %s' % (sys.argv[0], input) 53 return 60 plugins = newplugin.getPlugIns(IProcessor) 61 for plug in plugins: 62 if plug.name == input: 63 module = reflect.namedModule(plug.moduleName) 64 break 65 else: 66 # try treating it as a module name 67 try: 68 module = reflect.namedModule(input) 69 except ImportError: 70 print '%s: no such input: %s' % (sys.argv[0], input) 71 return 54 72 try: 55 73 return process.getProcessor(module, output, config) … … 60 78 def getWalker(df, opt): 61 79 klass = process.Walker 62 if opt['plain']: 80 if opt['plain']: 63 81 klass = process.PlainReportingWalker 64 if opt['null']: 82 if opt['null']: 65 83 klass = process.NullReportingWalker 66 84 return klass(df, opt['inputext'], opt['linkrel']) -
trunk/twisted/python/dist.py
r13096 r13168 35 35 36 36 kw['packages'] = getPackages(projdir, parent='twisted') 37 38 plugin = "twisted/plugins/twisted_" + projname + ".py" 39 if os.path.exists(plugin): 40 kw.setdefault('py_modules', []).append(plugin.replace("/", ".")[:-3]) 41 37 42 kw['data_files'] = getDataFiles(projdir, parent='twisted') 43 38 44 del kw['twisted_subproject'] 45 else: 46 if 'plugins' in kw: 47 py_modules = [] 48 for plg in kw['plugins']: 49 py_modules.append("twisted.plugins." + plg) 50 kw.setdefault('py_modules', []).extend(py_modules) 51 del kw['plugins'] 52 39 53 if 'cmdclass' not in kw: 40 54 kw['cmdclass'] = { -
trunk/twisted/python/plugin.py
r12868 r13168 34 34 def isLoaded(self): 35 35 """Check to see if the module for this plugin has been imported yet. 36 36 37 37 @rtype: C{int} 38 38 @return: A true value if the module for this plugin has been loaded, … … 43 43 def load(self): 44 44 """Load the module for this plugin. 45 45 46 46 @rtype: C{ModuleType} 47 47 @return: The module object that is loaded. … … 66 66 """Register a new plug-in. 67 67 """ 68 warnings.warn("The twisted.python.plugin system is deprecated. " 69 "See twisted.plugin for the revised edition.", 70 DeprecationWarning, 2) 68 71 self.plugins.append(PlugIn(name, module, **kw)) 69 72 … … 99 102 debug information about the loading process. If it is any other true value, 100 103 this debug information is written to stdout (This behavior is deprecated). 101 104 102 105 @type showProgress: C{None} or a callable taking one argument. 103 106 @param showProgress: If not None, this is invoked with floating point 104 values between 0 and 1 describing the progress of the loading process. 107 values between 0 and 1 describing the progress of the loading process. 105 108 If it is any other true value, this progress information is written to 106 109 stdout. (This behavior is deprecated). … … 127 130 loaded = {} 128 131 seenNames = {} 129 132 130 133 # XXX Some people claim to have found non-strings in sys.path (an empty 131 134 # list, in particular). Instead of tracking down the cause for their … … 133 136 # without further investigation. At some point, someone should track 134 137 # down where non-strings are coming from and do something about them. 135 paths = [cacheTransform(p) for p in sys.path 138 paths = [cacheTransform(p) for p in sys.path 136 139 if isinstance(p, str) and os.path.isdir(p)] 137 140 … … 194 197 against the C{type} argument to the C{register} function in the 195 198 plugin.tml files. 196 199 197 200 @type fileList: C{list} of C{str} 198 201 @param fileList: A list of the files to attempt to load plugin 199 202 information from. One name is put in their scope, the C{register} 200 203 function. 201 204 202 205 @type debugInspection: C{None} or a callable taking one argument 203 206 @param debugInspection: If not None, this is invoked with strings containing 204 207 debug information about the loading process. If it is any other true value, 205 208 this debug information is written to stdout (This behavior is deprecated). 206 209 207 210 @type showProgress: C{None} or a callable taking one argument. 208 211 @param showProgress: If not None, this is invoked with floating point 209 values between 0 and 1 describing the progress of the loading process. 212 values between 0 and 1 describing the progress of the loading process. 210 213 If it is any other true value, this progress information is written to 211 214 stdout. (This behavior is deprecated). … … 218 221 "int parameter for debugInspection is deprecated, pass None or " 219 222 "a function that takes a single argument instead.", 220 DeprecationWarning, 2223 DeprecationWarning, 4 221 224 ) 222 225 if isinstance(showProgress, types.IntType): … … 224 227 "int parameter for showProgress is deprecated, pass None or " 225 228 "a function that takes a single argument instead.", 226 DeprecationWarning, 2229 DeprecationWarning, 4 227 230 ) 228 231 result = [] 229 232 debugInspection, showProgress = _prepCallbacks(debugInspection, showProgress) 230 233 231 234 if not fileList: 232 235 raise ValueError("No plugins passed to loadPlugins") … … 240 243 pname = os.path.split(os.path.abspath(tmlFile))[-2] 241 244 dropin = DropIn(pname) 242 ns = {'register': dropin.register }245 ns = {'register': dropin.register, '__name__': tmlFile} 243 246 try: 244 247 execfile(tmlFile, ns) … … 247 250 debugInspection("Error loading: %s" % e) 248 251 continue 249 252 250 253 ldp = len(dropin.plugins) or 1.0 251 254 incr = increments * (1.0 / ldp) … … 266 269 def getPlugIns(plugInType, debugInspection=None, showProgress=None): 267 270 """Helper function to get all the plugins of a particular type. 268 271 269 272 @type plugInType: C{str} 270 273 @param plugInType: The type of plugin to search for. This is tested 271 274 against the C{type} argument to the C{register} function in the 272 275 plugin.tml files. 273 276 274 277 @type debugInspection: C{None} or a callable taking one argument 275 278 @param debugInspection: If not None, this is invoked with strings containing 276 279 debug information about the loading process. If it is any other true value, 277 280 this debug information is written to stdout (This behavior is deprecated). 278 281 279 282 @type showProgress: C{None} or a callable taking one argument. 280 283 @param showProgress: If not None, this is invoked with floating point 281 values between 0 and 1 describing the progress of the loading process. 284 values between 0 and 1 describing the progress of the loading process. 282 285 If it is any other true value, this progress information is written to 283 286 stdout. (This behavior is deprecated). … … 286 289 @return: A list of C{PlugIn} objects that were found. 287 290 """ 291 warnings.warn("The twisted.python.plugin system is deprecated. " 292 "See twisted.plugin for the revised edition.", 293 DeprecationWarning, 2) 294 return _getPlugIns(plugInType, debugInspection, showProgress) 295 296 def _getPlugIns(plugInType, debugInspection=None, showProgress=None): 288 297 if isinstance(debugInspection, types.IntType): 289 298 warnings.warn( 290 299 "int parameter for debugInspection is deprecated, pass None or " 291 300 "a function that takes a single argument instead.", 292 DeprecationWarning, 2301 DeprecationWarning, 3 293 302 ) 294 303 if isinstance(showProgress, types.IntType): … … 296 305 "int parameter for showProgress is deprecated, pass None or " 297 306 "a function that takes a single argument instead.", 298 DeprecationWarning, 2307 DeprecationWarning, 3 299 308 ) 300 309 debugInspection, showProgress = _prepCallbacks(debugInspection, showProgress) -
trunk/twisted/scripts/mktap.py
r13136 r13168 1 2 1 # Copyright (c) 2001-2004 Twisted Matrix Laboratories. 3 2 # See LICENSE for details. 4 3 5 # 4 import sys, os 5 6 from zope.interface import Interface, Attribute, implements 7 from twisted.python.components import backwardsCompatImplements 8 6 9 from twisted.application import service, compat, app 7 10 from twisted.persisted import sob 8 from twisted.python import usage, util, plugin 9 import sys, os 11 from twisted.python import log, usage, util, plugin as oldplugin 12 from twisted import plugin as newplugin 13 14 class IServiceMaker(Interface): 15 name = Attribute( 16 "A brief string naming this TAP plugin, for example \"Mega Crusher 2000\".") 17 18 tapname = Attribute( 19 "A short string naming this TAP plugin, for example \"web\" or " 20 "\"pencil\".") 21 22 description = Attribute( 23 "A brief summary of the features provided by this TAP plugin.") 24 25 options = Attribute( 26 "A C{twisted.python.usage.Options} subclass defining the" 27 "configuration options for this application.") 28 29 def makeService(options): 30 """Create an object implementing C{twisted.application.service.IService} 31 32 Configure the object according to the specified options. 33 34 @param options: A mapping (typically a C{dict} or 35 C{twisted.python.usage.Options} instance) of configuration 36 options to desired configuration values. 37 """ 38 10 39 try: 11 40 import pwd, grp … … 33 62 34 63 def loadPlugins(debug = None, progress = None): 35 plugins = plugin.getPlugIns("tap", debug, progress)36 64 tapLookup = {} 65 66 plugins = oldplugin._getPlugIns("tap", debug, progress) 37 67 for plug in plugins: 38 68 if hasattr(plug, 'tapname'): … … 41 71 shortTapName = plug.module.split('.')[-1] 42 72 tapLookup[shortTapName] = plug 73 74 plugins = newplugin.getPlugIns(IServiceMaker) 75 for plug in plugins: 76 tapLookup[plug.tapname] = plug 77 43 78 return tapLookup 44 79 … … 95 130 96 131 def init(self, tapLookup): 97 sc = [ [name, None, (lambda obj=module:obj.load().Options()), 98 getattr(module, 'description', '')] 99 for name, module in tapLookup.items()] 132 sc = [] 133 for (name, module) in tapLookup.iteritems(): 134 if IServiceMaker.providedBy(module): 135 sc.append(( 136 name, None, lambda m=module: m.options, module.description)) 137 else: 138 sc.append(( 139 name, None, lambda obj=module: obj.load().Options(), 140 getattr(module, 'description', ''))) 141 100 142 sc.sort() 101 143 self.subCommands = sc … … 148 190 except KeyboardInterrupt: 149 191 sys.exit(1) 150 ser = makeService(options.tapLookup[options.subCommand].load(), 151 options.subCommand, 152 options.subOptions) 192 193 plg = options.tapLookup[options.subCommand] 194 if not IServiceMaker.providedBy(plg): 195 plg = plg.load() 196 ser = makeService(plg, options.subCommand, options.subOptions) 153 197 addToApplication(ser, 154 198 options.subCommand, options['append'], options['appname'], 155 199 options['type'], options['encrypted'], 156 200 *getid(options['uid'], options['gid'])) 201 202 from twisted.python.reflect import namedAny 203 from twisted.plugin import IPlugin 204 205 class _tapHelper(object): 206 """ 207 Internal utility class to simplify the definition of \"new-style\" 208 mktap plugins based on existing, \"classic\" mktap plugins. 209 """ 210 211 implements(IPlugin, IServiceMaker) 212 213 def __init__(self, name, module, description, tapname): 214 self.name = name 215 self.module = module 216 self.description = description 217 self.tapname = tapname 218 219 def options(): 220 def get(self): 221 return namedAny(self.module).Options 222 return get, 223 options = property(*options()) 224 225 def makeService(): 226 def get(self): 227 return namedAny(self.module).makeService 228 return get, 229 makeService = property(*makeService()) 230 backwardsCompatImplements(_tapHelper) -
trunk/twisted/scripts/trial.py
r13118 r13168 15 15 16 16 from twisted.application import app 17 from twisted.python import usage, reflect, failure, log, plugin 17 from twisted.python import usage, reflect, failure, log 18 from twisted import plugin 18 19 from twisted.python.util import spewer 19 20 from twisted.spread import jelly … … 124 125 def _loadReporters(self): 125 126 self.pluginFlags, self.optToQual = [], {} 126 self.plugins = plugin.getPlugIns( "trial_reporter", None, None)127 self.plugins = plugin.getPlugIns(itrial.IReporter) 127 128 for p in self.plugins: 128 129 self.pluginFlags.append([p.longOpt, p.shortOpt, p.description]) -
trunk/twisted/topfiles/setup.py
r13126 r13168 94 94 95 95 # build stuff 96 packages=dist.getPackages('twisted', ignore=dist.twisted_subprojects), 96 packages=dist.getPackages('twisted', ignore=dist.twisted_subprojects + ['plugins']), 97 plugins=['__init__', 'notestplugin', 'testplugin', 'twisted_ftp', 'twisted_inet', 98 'twisted_manhole', 'twisted_portforward', 'twisted_socks', 'twisted_telnet', 99 'twisted_trial'], 97 100 data_files=dist.getDataFiles('twisted', ignore=dist.twisted_subprojects), 98 101 detectExtensions=detectExtensions, -
trunk/twisted/words/botbot.py
r2860 r13168 5 5 # Twisted Imports 6 6 from twisted.words.service import WordsClient 7 from twisted.python.plugin import getPlugIns8 7 from twisted.python.failure import Failure 9 from twisted.python import log 8 from twisted.python import log, plugin as oldplugin 9 from twisted import plugin as newplugin 10 11 from zope.interface import Interface 12 13 class IBotBot(Interface): 14 def createBot(): 15 """Create a bot... bot. 16 17 No one uses this code, who cares what this method does. 18 """ 10 19 11 20 class BotBot(WordsClient): … … 48 57 49 58 def loadBotList(self): 50 botTypeList = getPlugIns("twisted.words.bot")51 59 botTypes = {} 60 61 botTypeList = newplugin.getPlugIns(IBotBot) 52 62 for bott in botTypeList: 53 63 botTypes[bott.botType] = bott 64 65 botTypeList = oldplugin.getPlugIns("twisted.words.bot") 66 for bott in botTypeList: 67 botTypes[bott.botType] = bott.load() 68 54 69 self.botTypes = botTypes 55 70 … … 75 90 def bot_new(self, sender, message, metadata): 76 91 bottype, botname = string.split(message, ' ', 1) 77 self.voice.service.addBot(botname, self.botTypes[bottype]. load().createBot())92 self.voice.service.addBot(botname, self.botTypes[bottype].createBot()) 78 93 self.voice.directMessage(sender, "Bot Created!") 79 94
