/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/bedding.py

  • Committer: Jelmer Vernooij
  • Date: 2020-08-10 15:00:17 UTC
  • mfrom: (7490.40.99 work)
  • mto: This revision was merged to the branch mainline in revision 7521.
  • Revision ID: jelmer@jelmer.uk-20200810150017-vs7xnrd1vat4iktg
Merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
"""Functions for deriving user configuration from system environment."""
19
19
 
20
 
from __future__ import absolute_import
21
 
 
22
20
import os
23
21
import sys
24
22
 
33
31
from . import (
34
32
    errors,
35
33
    )
36
 
from .sixish import (
37
 
    PY3,
38
 
    )
39
34
 
40
35
 
41
36
def ensure_config_dir_exists(path=None):
68
63
 
69
64
    TODO: Global option --config-dir to override this.
70
65
    """
71
 
    base = osutils.path_from_environ('BZR_HOME')
 
66
    base = os.environ.get('BZR_HOME')
72
67
    if sys.platform == 'win32':
73
68
        if base is None:
74
69
            base = win32utils.get_appdata_location()
76
71
            base = win32utils.get_home_location()
77
72
        return osutils.pathjoin(base, 'bazaar', '2.0')
78
73
    if base is None:
79
 
        xdg_dir = osutils.path_from_environ('XDG_CONFIG_HOME')
 
74
        xdg_dir = os.environ.get('XDG_CONFIG_HOME')
80
75
        if xdg_dir is None:
81
76
            xdg_dir = osutils.pathjoin(osutils._get_home_dir(), ".config")
82
77
        xdg_dir = osutils.pathjoin(xdg_dir, 'bazaar')
96
91
    the bazaar one (see bazaar_config_dir()) does, use that instead.
97
92
    """
98
93
    # TODO: Global option --config-dir to override this.
99
 
    base = osutils.path_from_environ('BRZ_HOME')
 
94
    base = os.environ.get('BRZ_HOME')
100
95
    if sys.platform == 'win32':
101
96
        if base is None:
102
97
            base = win32utils.get_appdata_location()
103
98
        if base is None:
104
99
            base = win32utils.get_home_location()
105
100
    if base is None:
106
 
        base = osutils.path_from_environ('XDG_CONFIG_HOME')
 
101
        base = os.environ.get('XDG_CONFIG_HOME')
107
102
        if base is None:
108
103
            base = osutils.pathjoin(osutils._get_home_dir(), ".config")
109
104
    breezy_dir = osutils.pathjoin(base, 'breezy')
171
166
 
172
167
def cache_dir():
173
168
    """Return the cache directory to use."""
174
 
    base = osutils.path_from_environ('BRZ_HOME')
 
169
    base = os.environ.get('BRZ_HOME')
175
170
    if sys.platform in "win32":
176
171
        if base is None:
177
172
            base = win32utils.get_local_appdata_location()
178
173
        if base is None:
179
174
            base = win32utils.get_home_location()
180
175
    else:
181
 
        base = osutils.path_from_environ('XDG_CACHE_HOME')
 
176
        base = os.environ.get('XDG_CACHE_HOME')
182
177
        if base is None:
183
178
            base = osutils.pathjoin(osutils._get_home_dir(), ".cache")
184
179
 
213
208
def default_email():
214
209
    v = os.environ.get('BRZ_EMAIL')
215
210
    if v:
216
 
        if not PY3:
217
 
            v = v.decode(osutils.get_user_encoding())
218
211
        return v
219
212
    v = os.environ.get('EMAIL')
220
213
    if v:
221
 
        if not PY3:
222
 
            v = v.decode(osutils.get_user_encoding())
223
214
        return v
224
215
    name, email = _auto_user_id()
225
216
    if name and email: