~ubuntu-branches/ubuntu/karmic/bzr/karmic-proposed

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2009-03-10 14:11:59 UTC
  • mfrom: (1.1.49 upstream) (3.1.3 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090310141159-0q0938373dnw9qw2
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
plugins.
27
27
 
28
28
BZR_PLUGIN_PATH is also honoured for any plugins imported via
29
 
'import bzrlib.plugins.PLUGINNAME', as long as set_plugins_path has been 
 
29
'import bzrlib.plugins.PLUGINNAME', as long as set_plugins_path has been
30
30
called.
31
31
"""
32
32
 
190
190
 
191
191
def load_from_dir(d):
192
192
    """Load the plugins in directory d.
193
 
    
 
193
 
194
194
    d must be in the plugins module path already.
195
195
    """
196
196
    # Get the list of valid python suffixes for __init__.py?
226
226
        else:
227
227
            # trace.mutter('add plugin name %s', f)
228
228
            plugin_names.add(f)
229
 
    
 
229
 
230
230
    for name in plugin_names:
231
231
        try:
232
232
            exec "import bzrlib.plugins.%s" % name in {}
287
287
                    if name.startswith(prefix)]
288
288
 
289
289
    trace.mutter('Names in archive: %r', namelist)
290
 
    
 
290
 
291
291
    for name in namelist:
292
292
        if not name or name.endswith('/'):
293
293
            continue
294
 
    
 
294
 
295
295
        # '/' is used to separate pathname components inside zip archives
296
296
        ix = name.rfind('/')
297
297
        if ix == -1:
301
301
        if '/' in head:
302
302
            # we don't need looking in subdirectories
303
303
            continue
304
 
    
 
304
 
305
305
        base, suffix = osutils.splitext(tail)
306
306
        if suffix not in valid_suffixes:
307
307
            continue
308
 
    
 
308
 
309
309
        if base == '__init__':
310
310
            # package
311
311
            plugin_name = head
314
314
            plugin_name = base
315
315
        else:
316
316
            continue
317
 
    
 
317
 
318
318
        if not plugin_name:
319
319
            continue
320
320
        if getattr(_mod_plugins, plugin_name, None):
321
321
            trace.mutter('Plugin name %s already loaded', plugin_name)
322
322
            continue
323
 
    
 
323
 
324
324
        try:
325
325
            exec "import bzrlib.plugins.%s" % plugin_name in {}
326
326
            trace.mutter('Load plugin %s from zip %r', plugin_name, zip_name)
337
337
 
338
338
def plugins():
339
339
    """Return a dictionary of the plugins.
340
 
    
 
340
 
341
341
    Each item in the dictionary is a PlugIn object.
342
342
    """
343
343
    result = {}
397
397
            result = self.module.__doc__
398
398
        if result[-1] != '\n':
399
399
            result += '\n'
400
 
        # there is code duplicated here and in bzrlib/help_topic.py's 
 
400
        # there is code duplicated here and in bzrlib/help_topic.py's
401
401
        # matching Topic code. This should probably be factored in
402
402
        # to a helper function and a common base class.
403
403
        if additional_see_also is not None: