/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-03-14 20:21:53 UTC
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080314202153-ws2nepff7epep8rt
Replace some duplication with a different form of hackery.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
import zipfile
41
41
 
42
42
from bzrlib import (
 
43
    config,
43
44
    osutils,
44
45
    trace,
45
46
    )
52
53
DEFAULT_PLUGIN_PATH = None
53
54
_loaded = False
54
55
 
55
 
# XXX: copied and pasted from config.py to avoid importing configobj before
56
 
#      we've installed lazy_regex.
57
 
def _config_dir():
58
 
    """Return per-user configuration directory.
59
 
 
60
 
    By default this is ~/.bazaar/
61
 
    
62
 
    TODO: Global option --config-dir to override this.
63
 
    """
64
 
    base = os.environ.get('BZR_HOME', None)
65
 
    if sys.platform == 'win32':
66
 
        if base is None:
67
 
            base = win32utils.get_appdata_location_unicode()
68
 
        if base is None:
69
 
            base = os.environ.get('HOME', None)
70
 
        if base is None:
71
 
            raise errors.BzrError('You must have one of BZR_HOME, APPDATA,'
72
 
                                  ' or HOME set')
73
 
        return osutils.pathjoin(base, 'bazaar', '2.0')
74
 
    else:
75
 
        # cygwin, linux, and darwin all have a $HOME directory
76
 
        if base is None:
77
 
            base = os.path.expanduser("~")
78
 
        return osutils.pathjoin(base, ".bazaar")
79
 
 
80
 
 
81
56
def get_default_plugin_path():
82
57
    """Get the DEFAULT_PLUGIN_PATH"""
83
58
    global DEFAULT_PLUGIN_PATH
84
59
    if DEFAULT_PLUGIN_PATH is None:
85
 
        DEFAULT_PLUGIN_PATH = osutils.pathjoin(_config_dir(), 'plugins')
 
60
        DEFAULT_PLUGIN_PATH = osutils.pathjoin(config.config_dir(), 'plugins')
86
61
    return DEFAULT_PLUGIN_PATH
87
62
 
88
63