/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 17:07:55 UTC
  • mto: This revision was merged to the branch mainline in revision 3756.
  • Revision ID: andrew.bennetts@canonical.com-20080314170755-th4th2bapqdzowxa
More initial import 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,
44
43
    osutils,
45
44
    trace,
46
45
    )
53
52
DEFAULT_PLUGIN_PATH = None
54
53
_loaded = False
55
54
 
 
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
 
56
81
def get_default_plugin_path():
57
82
    """Get the DEFAULT_PLUGIN_PATH"""
58
83
    global DEFAULT_PLUGIN_PATH
59
84
    if DEFAULT_PLUGIN_PATH is None:
60
 
        DEFAULT_PLUGIN_PATH = osutils.pathjoin(config.config_dir(), 'plugins')
 
85
        DEFAULT_PLUGIN_PATH = osutils.pathjoin(_config_dir(), 'plugins')
61
86
    return DEFAULT_PLUGIN_PATH
62
87
 
63
88