245
245
The python module path for bzrlib.plugins will be modified to be 'dirs'.
247
for fullname, path in PluginImporter.specific_paths.iteritems():
248
name = fullname[len('bzrlib.plugins.'):]
249
_load_plugin_module(name, path) # XXX: path *contains* test_foo
247
251
# We need to strip the trailing separators here as well as in the
248
252
# set_plugins_path function because calling code can pass anything in to
249
253
# this function, and since it sets plugins.__path__, it should set it to
296
300
return None, None, (None, None, None)
303
def _load_plugin_module(name, dir):
304
if ('bzrlib.plugins.%s' % name) in PluginImporter.blacklist:
307
exec "import bzrlib.plugins.%s" % name in {}
308
except KeyboardInterrupt:
310
except errors.IncompatibleAPI, e:
311
trace.warning("Unable to load plugin %r. It requested API version "
312
"%s of module %s but the minimum exported version is %s, and "
313
"the maximum is %s" %
314
(name, e.wanted, e.api, e.minimum, e.current))
316
trace.warning("%s" % e)
317
if re.search('\.|-| ', name):
318
sanitised_name = re.sub('[-. ]', '_', name)
319
if sanitised_name.startswith('bzr_'):
320
sanitised_name = sanitised_name[len('bzr_'):]
321
trace.warning("Unable to load %r in %r as a plugin because the "
322
"file path isn't a valid module name; try renaming "
323
"it to %r." % (name, dir, sanitised_name))
325
trace.warning('Unable to load plugin %r from %r' % (name, dir))
326
trace.log_exception_quietly()
327
if 'error' in debug.debug_flags:
328
trace.print_exception(sys.exc_info(), sys.stderr)
299
331
def load_from_dir(d):
300
332
"""Load the plugins in directory d.
321
353
plugin_names.add(name)
323
355
for name in plugin_names:
324
if ('bzrlib.plugins.%s' % name) in PluginImporter.blacklist:
327
exec "import bzrlib.plugins.%s" % name in {}
328
except KeyboardInterrupt:
330
except errors.IncompatibleAPI, e:
331
trace.warning("Unable to load plugin %r. It requested API version "
332
"%s of module %s but the minimum exported version is %s, and "
333
"the maximum is %s" %
334
(name, e.wanted, e.api, e.minimum, e.current))
336
trace.warning("%s" % e)
337
if re.search('\.|-| ', name):
338
sanitised_name = re.sub('[-. ]', '_', name)
339
if sanitised_name.startswith('bzr_'):
340
sanitised_name = sanitised_name[len('bzr_'):]
341
trace.warning("Unable to load %r in %r as a plugin because the "
342
"file path isn't a valid module name; try renaming "
343
"it to %r." % (name, d, sanitised_name))
345
trace.warning('Unable to load plugin %r from %r' % (name, d))
346
trace.log_exception_quietly()
347
if 'error' in debug.debug_flags:
348
trace.print_exception(sys.exc_info(), sys.stderr)
356
_load_plugin_module(name, d)