~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Martin Pool
  • Date: 2005-06-27 01:26:11 UTC
  • Revision ID: mbp@sourcefrog.net-20050627012611-4effb7007553fde1
- tweak rsync upload script

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
# plugin_cmds variable.
24
24
 
25
25
 
26
 
import os
27
 
from bzrlib.osutils import config_dir
28
 
DEFAULT_PLUGIN_PATH = os.path.join(config_dir(), 'plugins')
 
26
DEFAULT_PLUGIN_PATH = '~/.bzr.conf/plugins'
29
27
 
30
28
all_plugins = []
31
 
_loaded = False
32
29
 
33
30
 
34
31
def load_plugins():
48
45
    such as *.pyd).
49
46
    """
50
47
 
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
 
 
58
48
    import sys, os, imp
59
 
    
 
49
    try:
 
50
        set
 
51
    except NameError:
 
52
        from sets import Set as set         # python2.3
 
53
 
60
54
    from bzrlib.trace import log_error, mutter, log_exception
61
55
    from bzrlib.errors import BzrError
62
56
 
63
 
    bzrpath = os.environ.get('BZR_PLUGIN_PATH', DEFAULT_PLUGIN_PATH)
 
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")
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)
 
113
                    all_plugins.append(plugin_info)
114
114
                finally:
115
115
                    if plugin_info[0] is not None:
116
116
                        plugin_info[0].close()