/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: 2019-03-05 07:32:38 UTC
  • mto: (7290.1.21 work)
  • mto: This revision was merged to the branch mainline in revision 7311.
  • Revision ID: jelmer@jelmer.uk-20190305073238-zlqn981opwnqsmzi
Add appveyor configuration.

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
plugins.
35
35
"""
36
36
 
 
37
from __future__ import absolute_import
 
38
 
37
39
import os
38
40
import re
39
41
import sys
47
49
from importlib import util as importlib_util
48
50
 
49
51
from breezy import (
50
 
    bedding,
 
52
    config,
51
53
    debug,
 
54
    errors,
52
55
    help_topics,
53
56
    trace,
54
57
    )
55
58
""")
56
59
 
57
 
from . import (
58
 
    errors,
59
 
    )
60
 
 
61
60
 
62
61
_MODULE_PREFIX = "breezy.plugins."
63
62
 
64
 
COMPILED_EXT = ".pyc"
 
63
if __debug__ or sys.version_info > (3,):
 
64
    COMPILED_EXT = ".pyc"
 
65
else:
 
66
    COMPILED_EXT = ".pyo"
65
67
 
66
68
 
67
69
def disable_plugins(state=None):
76
78
    state.plugins = {}
77
79
 
78
80
 
79
 
def load_plugins(path=None, state=None, warn_load_problems=True):
 
81
def load_plugins(path=None, state=None):
80
82
    """Load breezy plugins.
81
83
 
82
84
    The environment variable BRZ_PLUGIN_PATH is considered a delimited
103
105
    if (None, 'entrypoints') in _env_plugin_path():
104
106
        _load_plugins_from_entrypoints(state)
105
107
    state.plugins = plugins()
106
 
    if warn_load_problems:
107
 
        for plugin, errors in state.plugin_warnings.items():
108
 
            for error in errors:
109
 
                trace.warning('%s', error)
110
108
 
111
109
 
112
110
def _load_plugins_from_entrypoints(state):
193
191
def _env_disable_plugins(key='BRZ_DISABLE_PLUGINS'):
194
192
    """Gives list of names for plugins to disable from environ key."""
195
193
    disabled_names = []
196
 
    env = os.environ.get(key)
 
194
    env = osutils.path_from_environ(key)
197
195
    if env:
198
196
        for name in env.split(os.pathsep):
199
197
            name = _expect_identifier(name, key, env)
205
203
def _env_plugins_at(key='BRZ_PLUGINS_AT'):
206
204
    """Gives list of names and paths of specific plugins from environ key."""
207
205
    plugin_details = []
208
 
    env = os.environ.get(key)
 
206
    env = osutils.path_from_environ(key)
209
207
    if env:
210
208
        for pair in env.split(os.pathsep):
211
209
            if '@' in pair:
226
224
    'path', or None and one of the values 'user', 'core', 'entrypoints', 'site'.
227
225
    """
228
226
    path_details = []
229
 
    env = os.environ.get(key)
230
 
    defaults = {
231
 
        "user": not env,
232
 
        "core": True,
233
 
        "site": True,
234
 
        'entrypoints': False,
235
 
        }
 
227
    env = osutils.path_from_environ(key)
 
228
    defaults = {"user": not env, "core": True, "site": True, 'entrypoints': True}
236
229
    if env:
237
230
        # Add paths specified by user in order
238
231
        for p in env.split(os.pathsep):
409
402
 
410
403
 
411
404
def get_user_plugin_path():
412
 
    return osutils.pathjoin(bedding.config_dir(), 'plugins')
 
405
    return osutils.pathjoin(config.config_dir(), 'plugins')
413
406
 
414
407
 
415
408
def record_plugin_warning(warning_message):