/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: Andrew Bennetts
  • Date: 2008-04-10 07:58:01 UTC
  • mfrom: (3352 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3357.
  • Revision ID: andrew.bennetts@canonical.com-20080410075801-n24st9wfiizkvszp
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
    if not bzr_exe:     # don't look inside library.zip
101
101
        # search the plugin path before the bzrlib installed dir
102
102
        path.append(os.path.dirname(_mod_plugins.__file__))
 
103
    # search the arch independent path if we can determine that and
 
104
    # the plugin is found nowhere else
 
105
    if sys.platform != 'win32':
 
106
        try:
 
107
            from distutils.sysconfig import get_python_lib
 
108
        except ImportError:
 
109
            # If distutuils is not available, we just won't add that path
 
110
            pass
 
111
        else:
 
112
            archless_path = osutils.pathjoin(get_python_lib(), 'bzrlib',
 
113
                    'plugins')
 
114
            if archless_path not in path:
 
115
                path.append(archless_path)
103
116
    _mod_plugins.__path__ = path
104
117
    return path
105
118
 
199
212
            ## import pdb; pdb.set_trace()
200
213
            if re.search('\.|-| ', name):
201
214
                sanitised_name = re.sub('[-. ]', '_', name)
202
 
                warning("Unable to load %r in %r as a plugin because file path"
203
 
                        " isn't a valid module name; try renaming it to %r."
204
 
                        % (name, d, sanitised_name))
 
215
                if sanitised_name.startswith('bzr_'):
 
216
                    sanitised_name = sanitised_name[len('bzr_'):]
 
217
                warning("Unable to load %r in %r as a plugin because the "
 
218
                        "file path isn't a valid module name; try renaming "
 
219
                        "it to %r." % (name, d, sanitised_name))
205
220
            else:
206
221
                warning('Unable to load plugin %r from %r' % (name, d))
207
222
            log_exception_quietly()
405
420
        else:
406
421
            return None
407
422
 
 
423
    def load_plugin_tests(self, loader):
 
424
        """Return the adapted plugin's test suite.
 
425
 
 
426
        :param loader: The custom loader that should be used to load additional
 
427
            tests.
 
428
 
 
429
        """
 
430
        if getattr(self.module, 'load_tests', None) is not None:
 
431
            return loader.loadTestsFromModule(self.module)
 
432
        else:
 
433
            return None
 
434
 
408
435
    def version_info(self):
409
436
        """Return the plugin's version_tuple or None if unknown."""
410
437
        version_info = getattr(self.module, 'version_info', None)
411
438
        if version_info is not None and len(version_info) == 3:
412
439
            version_info = tuple(version_info) + ('final', 0)
413
440
        return version_info
414
 
    
 
441
 
415
442
    def _get__version__(self):
416
443
        version_info = self.version_info()
417
444
        if version_info is None: