~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Martin Pool
  • Date: 2005-08-19 21:39:05 UTC
  • Revision ID: mbp@sourcefrog.net-20050819213905-dcb792daf09efa84
prepare 0.0.6 release

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    _loaded = True
57
57
 
58
58
    import sys, os, imp
59
 
    try:
60
 
        set
61
 
    except NameError:
62
 
        from sets import Set as set         # python2.3
63
 
 
 
59
    
64
60
    from bzrlib.trace import log_error, mutter, log_exception
65
61
    from bzrlib.errors import BzrError
 
62
    from bzrlib import plugins
66
63
 
67
 
    bzrpath = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH)
 
64
    dirs = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH).split(":")
 
65
    dirs.insert(0, os.path.dirname(plugins.__file__))
68
66
 
69
67
    # The problem with imp.get_suffixes() is that it doesn't include
70
68
    # .pyo which is technically valid
74
72
    suffixes = imp.get_suffixes()
75
73
    suffixes.append(('.pyo', 'rb', imp.PY_COMPILED))
76
74
    package_entries = ['__init__.py', '__init__.pyc', '__init__.pyo']
77
 
    for d in bzrpath.split(os.pathsep):
 
75
    for d in dirs:
78
76
        # going through them one by one allows different plugins with the same
79
77
        # filename in different directories in the path
80
78
        mutter('looking for plugins in %s' % d)
114
112
                try:
115
113
                    plugin = imp.load_module('bzrlib.plugin.' + name,
116
114
                                             *plugin_info)
117
 
                    all_plugins.append(plugin_info)
 
115
                    all_plugins.append(plugin)
118
116
                finally:
119
117
                    if plugin_info[0] is not None:
120
118
                        plugin_info[0].close()