~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/plugin.py

  • Committer: Vincent Ladeuil
  • Date: 2010-06-09 17:49:54 UTC
  • mto: (5285.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 5286.
  • Revision ID: v.ladeuil+lp@free.fr-20100609174954-tg4xoej3vqb16syz
Reproduce bug #591215.

* bzrlib/tests/test_plugins.py:
(TestLoadPluginAtSyntax): Test valid and invalid values for
BZR_PLUGINS_AT.

* bzrlib/plugin.py:
(_get_specific_plugin_paths): Factor out and document how
BZR_PLUGINS_AT is parsed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
81
81
    return path.rstrip("\\/")
82
82
 
83
83
 
 
84
def _get_specific_plugin_paths(paths):
 
85
    """Returns the plugin paths from a string describing the associations.
 
86
 
 
87
    :param paths: A string describing the paths associated with the plugins.
 
88
 
 
89
    :returns: A list of (plugin name, path) tuples.
 
90
 
 
91
    For example, if paths is my_plugin@/test/my-test:her_plugin@/production/her,
 
92
    [('my_plugin', '/test/my-test'), ('her_plugin', '/production/her')] 
 
93
    will be returned.
 
94
 
 
95
    Note that ':' in the example above depends on the os.
 
96
    """
 
97
    if not paths:
 
98
        return []
 
99
    specs = []
 
100
    for spec in paths.split(os.pathsep):
 
101
        name, path = spec.split('@')
 
102
        specs.append((name, path))
 
103
    return specs
 
104
 
 
105
 
84
106
def set_plugins_path(path=None):
85
107
    """Set the path for plugins to be loaded from.
86
108
 
98
120
        for name in disabled_plugins.split(os.pathsep):
99
121
            PluginImporter.blacklist.add('bzrlib.plugins.' + name)
100
122
    # Set up a the specific paths for plugins
101
 
    specific_plugins = os.environ.get('BZR_PLUGINS_AT', None)
102
 
    if specific_plugins is not None:
103
 
        for spec in specific_plugins.split(os.pathsep):
104
 
            plugin_name, plugin_path = spec.split('@')
 
123
    for plugin_name, plugin_path in _get_specific_plugin_paths(os.environ.get(
 
124
            'BZR_PLUGINS_AT', None)):
105
125
            PluginImporter.specific_paths[
106
126
                'bzrlib.plugins.%s' % plugin_name] = plugin_path
107
127
    return path