/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: John Arbash Meinel
  • Date: 2008-07-08 14:55:19 UTC
  • mfrom: (3530 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3532.
  • Revision ID: john@arbash-meinel.com-20080708145519-paqg4kjwbpgs2xmq
Merge bzr.dev 3530

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
 
42
42
from bzrlib import (
43
43
    config,
 
44
    debug,
44
45
    osutils,
 
46
    trace,
45
47
    )
46
48
from bzrlib import plugins as _mod_plugins
47
49
""")
100
102
    if not bzr_exe:     # don't look inside library.zip
101
103
        # search the plugin path before the bzrlib installed dir
102
104
        path.append(os.path.dirname(_mod_plugins.__file__))
 
105
    # search the arch independent path if we can determine that and
 
106
    # the plugin is found nowhere else
 
107
    if sys.platform != 'win32':
 
108
        try:
 
109
            from distutils.sysconfig import get_python_lib
 
110
        except ImportError:
 
111
            # If distutuils is not available, we just won't add that path
 
112
            pass
 
113
        else:
 
114
            archless_path = osutils.pathjoin(get_python_lib(), 'bzrlib',
 
115
                    'plugins')
 
116
            if archless_path not in path:
 
117
                path.append(archless_path)
103
118
    _mod_plugins.__path__ = path
104
119
    return path
105
120
 
199
214
            ## import pdb; pdb.set_trace()
200
215
            if re.search('\.|-| ', name):
201
216
                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))
 
217
                if sanitised_name.startswith('bzr_'):
 
218
                    sanitised_name = sanitised_name[len('bzr_'):]
 
219
                warning("Unable to load %r in %r as a plugin because the "
 
220
                        "file path isn't a valid module name; try renaming "
 
221
                        "it to %r." % (name, d, sanitised_name))
205
222
            else:
206
223
                warning('Unable to load plugin %r from %r' % (name, d))
207
224
            log_exception_quietly()
 
225
            if 'error' in debug.debug_flags:
 
226
                trace.print_exception(sys.exc_info(), sys.stderr)
208
227
 
209
228
 
210
229
@deprecated_function(one_three)
284
303
            warning('Unable to load plugin %r from %r'
285
304
                    % (name, zip_name))
286
305
            log_exception_quietly()
 
306
            if 'error' in debug.debug_flags:
 
307
                trace.print_exception(sys.exc_info(), sys.stderr)
287
308
 
288
309
 
289
310
def plugins():
405
426
        else:
406
427
            return None
407
428
 
 
429
    def load_plugin_tests(self, loader):
 
430
        """Return the adapted plugin's test suite.
 
431
 
 
432
        :param loader: The custom loader that should be used to load additional
 
433
            tests.
 
434
 
 
435
        """
 
436
        if getattr(self.module, 'load_tests', None) is not None:
 
437
            return loader.loadTestsFromModule(self.module)
 
438
        else:
 
439
            return None
 
440
 
408
441
    def version_info(self):
409
442
        """Return the plugin's version_tuple or None if unknown."""
410
443
        version_info = getattr(self.module, 'version_info', None)
411
444
        if version_info is not None and len(version_info) == 3:
412
445
            version_info = tuple(version_info) + ('final', 0)
413
446
        return version_info
414
 
    
 
447
 
415
448
    def _get__version__(self):
416
449
        version_info = self.version_info()
417
450
        if version_info is None: