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

  • Committer: Martin
  • Date: 2019-06-16 01:03:51 UTC
  • mto: This revision was merged to the branch mainline in revision 7340.
  • Revision ID: gzlist@googlemail.com-20190616010351-uz89ydnwdoal4ve4
Split non-ini config methods to bedding

Functions that determine filesystem paths to use for config and default
username are now outside of the main (large) config module.

Also move cache_dir function from osutils and normalise logic.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2634
2634
    return False
2635
2635
 
2636
2636
 
2637
 
def cache_dir():
2638
 
    """Return the cache directory to use."""
2639
 
    if sys.platform in ("nt", "win32"):
2640
 
        from bzrlib.win32utils import get_local_appdata_location
2641
 
        s = get_local_appdata_location()
2642
 
        # This can return a unicode string or a plain string in
2643
 
        # user encoding
2644
 
        if isinstance(s, bytes):
2645
 
            s = s.decode(bzrlib.user_encoding)
2646
 
        cache_dir = s.encode(_fs_enc)
2647
 
    else:
2648
 
        try:
2649
 
            from xdg import BaseDirectory
2650
 
        except ImportError:
2651
 
            xdg_cache_dir = os.environ.get('XDG_CACHE_HOME', None)
2652
 
        else:
2653
 
            xdg_cache_dir = BaseDirectory.xdg_cache_home
2654
 
        if xdg_cache_dir is not None:
2655
 
            cache_dir = os.path.join(xdg_cache_dir, "breezy")
2656
 
        else:
2657
 
            cache_dir = None
2658
 
        if cache_dir is not None and not isinstance(cache_dir, text_type):
2659
 
            cache_dir = cache_dir.encode(_fs_enc)
2660
 
 
2661
 
    if cache_dir is None:
2662
 
        cache_dir = os.path.expanduser('~/.cache/breezy')
2663
 
 
2664
 
    if not os.path.exists(cache_dir):
2665
 
        os.makedirs(cache_dir)
2666
 
 
2667
 
    return cache_dir
2668
 
 
2669
 
 
2670
2637
def get_fs_type(path):
2671
2638
    """Return the filesystem type for the partition a path is in.
2672
2639