~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

merge from aaron - fixes bare excepts, adds ancestor namespace

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)
118
116
                finally:
119
117
                    if plugin_info[0] is not None:
120
118
                        plugin_info[0].close()
121
 
            except Exception, e:
 
119
 
 
120
                mutter('loaded succesfully')
 
121
            except:
122
122
                log_error('Unable to load plugin %r from %r' % (name, d))
123
 
                log_error(str(e))
124
123
                log_exception()
125
124