/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Lukáš Lalinský
  • Date: 2007-12-17 17:28:25 UTC
  • mfrom: (3120 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3123.
  • Revision ID: lalinsky@gmail.com-20071217172825-tr3pqm1mhvs3gwnn
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
57
57
    """Get the DEFAULT_PLUGIN_PATH"""
58
58
    global DEFAULT_PLUGIN_PATH
59
59
    if DEFAULT_PLUGIN_PATH is None:
60
 
        DEFAULT_PLUGIN_PATH = osutils.pathjoin(config.config_dir(), 'plugins')
 
60
        path = [osutils.pathjoin(config.config_dir(), 'plugins')]
 
61
        if getattr(sys, 'frozen', None):    # bzr.exe
 
62
            # We need to use relative path to system-wide plugin
 
63
            # directory because bzrlib from standalone bzr.exe
 
64
            # could be imported by another standalone program
 
65
            # (e.g. bzr-config; or TortoiseBzr/Olive if/when they
 
66
            # will become standalone exe). [bialix 20071123]
 
67
            # __file__ typically is
 
68
            # C:\Program Files\Bazaar\lib\library.zip\bzrlib\plugin.pyc
 
69
            # then plugins directory is
 
70
            # C:\Program Files\Bazaar\plugins
 
71
            # so relative path is ../../../plugins
 
72
            path.append(osutils.abspath(osutils.pathjoin(
 
73
                osutils.dirname(__file__), '../../../plugins')))
 
74
        DEFAULT_PLUGIN_PATH = os.pathsep.join(path)
61
75
    return DEFAULT_PLUGIN_PATH
62
76
 
63
77
 
77
91
    global _loaded
78
92
    _loaded = True
79
93
 
 
94
 
80
95
def _strip_trailing_sep(path):
81
96
    return path.rstrip("\\/")
82
97
 
 
98
 
83
99
def set_plugins_path():
84
100
    """Set the path for plugins to be loaded from."""
85
101
    path = os.environ.get('BZR_PLUGIN_PATH',
141
157
        else:
142
158
            # it might be a zip: try loading from the zip.
143
159
            load_from_zip(d)
144
 
            continue
145
160
 
146
161
 
147
162
# backwards compatability: load_from_dirs was the old name
191
206
        except Exception, e:
192
207
            ## import pdb; pdb.set_trace()
193
208
            if re.search('\.|-| ', name):
194
 
                warning('Unable to load plugin %r from %r: '
195
 
                    'It is not a valid python module name.' % (name, d))
 
209
                sanitised_name = re.sub('[-. ]', '_', name)
 
210
                warning("Unable to load %r in %r as a plugin because file path"
 
211
                        " isn't a valid module name; try renaming it to %r."
 
212
                        % (name, d, sanitised_name))
196
213
            else:
197
214
                warning('Unable to load plugin %r from %r' % (name, d))
198
215
            log_exception_quietly()