~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Martin Pool
  • Date: 2005-07-23 13:52:38 UTC
  • Revision ID: mbp@sourcefrog.net-20050723135238-96b1580de8dff136
doc

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# plugin_cmds variable.
24
24
 
25
25
 
26
 
DEFAULT_PLUGIN_PATH = '~/.bzr.conf/plugins'
 
26
import os
 
27
from bzrlib.osutils import config_dir
 
28
DEFAULT_PLUGIN_PATH = os.path.join(config_dir(), 'plugins')
27
29
 
28
30
all_plugins = []
 
31
_loaded = False
29
32
 
30
33
 
31
34
def load_plugins():
45
48
    such as *.pyd).
46
49
    """
47
50
 
 
51
    global all_plugins, _loaded
 
52
    if _loaded:
 
53
        # People can make sure plugins are loaded, they just won't be twice
 
54
        return
 
55
        #raise BzrError("plugins already initialized")
 
56
    _loaded = True
 
57
 
48
58
    import sys, os, imp
49
 
    try:
50
 
        set
51
 
    except NameError:
52
 
        from sets import Set as set         # python2.3
53
 
 
 
59
    
54
60
    from bzrlib.trace import log_error, mutter, log_exception
55
61
    from bzrlib.errors import BzrError
56
62
 
57
 
    bzrpath = os.environ.get('BZR_PLUGIN_PATH')
58
 
    if not bzrpath:
59
 
        bzrpath = os.path.expanduser(DEFAULT_PLUGIN_PATH)
60
 
 
61
 
    global all_plugins
62
 
    if all_plugins:
63
 
        raise BzrError("plugins already initialized")
 
63
    bzrpath = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH)
64
64
 
65
65
    # The problem with imp.get_suffixes() is that it doesn't include
66
66
    # .pyo which is technically valid
110
110
                try:
111
111
                    plugin = imp.load_module('bzrlib.plugin.' + name,
112
112
                                             *plugin_info)
113
 
                    all_plugins.append(plugin_info)
 
113
                    all_plugins.append(plugin)
114
114
                finally:
115
115
                    if plugin_info[0] is not None:
116
116
                        plugin_info[0].close()