/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 breezy/plugin.py

  • Committer: Jelmer Vernooij
  • Date: 2017-08-30 04:41:26 UTC
  • mfrom: (6759.4.7 initialization)
  • Revision ID: jelmer@jelmer.uk-20170830044126-jq95dme3hbybw1qo
Merge lp:~jelmer/brz/initialization.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    :param state: The library state object that records loaded plugins.
76
76
    """
77
77
    if state is None:
78
 
        state = breezy.global_state
 
78
        state = breezy.get_global_state()
79
79
    state.plugins = {}
80
80
 
81
81
 
92
92
    :param state: The library state object that records loaded plugins.
93
93
    """
94
94
    if state is None:
95
 
        state = breezy.global_state
 
95
        state = breezy.get_global_state()
96
96
    if getattr(state, 'plugins', None) is not None:
97
97
        # People can make sure plugins are loaded, they just won't be twice
98
98
        return
332
332
    :returns: Iterator of text lines (including newlines.)
333
333
    """
334
334
    if state is None:
335
 
        state = breezy.global_state
336
 
    all_names = sorted(set(state.plugins).union(state.plugin_warnings))
 
335
        state = breezy.get_global_state()
 
336
    loaded_plugins = getattr(state, 'plugins', {})
 
337
    plugin_warnings = set(getattr(state, 'plugin_warnings', []))
 
338
    all_names = sorted(set(loaded_plugins.keys()).union(plugin_warnings))
337
339
    for name in all_names:
338
 
        if name in state.plugins:
339
 
            plugin = state.plugins[name]
 
340
        if name in loaded_plugins:
 
341
            plugin = loaded_plugins[name]
340
342
            version = plugin.__version__
341
343
            if version == 'unknown':
342
344
                version = ''
441
443
    return result
442
444
 
443
445
 
 
446
def get_loaded_plugin(name):
 
447
    """Retrieve an already loaded plugin.
 
448
 
 
449
    Returns None if there is no such plugin loaded
 
450
    """
 
451
    try:
 
452
        module = sys.modules[_MODULE_PREFIX + name]
 
453
    except KeyError:
 
454
        return None
 
455
    return PlugIn(name, module)
 
456
 
 
457
 
444
458
def format_concise_plugin_list(state=None):
445
459
    """Return a string holding a concise list of plugins and their version.
446
460
    """
447
461
    if state is None:
448
 
        state = breezy.global_state
 
462
        state = breezy.get_global_state()
449
463
    items = []
450
464
    for name, a_plugin in sorted(state.plugins.items()):
451
465
        items.append("%s[%s]" %