~dobey/tarmac/plugins-tests

« back to all changes in this revision

Viewing changes to tarmac/xdgdirs.py

  • Committer: Tarmac
  • Author(s): Gavin Panella
  • Date: 2010-09-02 20:45:59 UTC
  • mfrom: (345.2.3 lint-fixes)
  • Revision ID: paul@eventuallyanyway.com-20100902204559-pp01ph3bcli0hdnk
Fix all pyflakes and pep8 warnings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with Tarmac.  If not, see <http://www.gnu.org/licenses/>.
16
16
 
17
17
'''XDG BaseDirectory abstraction for non-Linux platforms.'''
 
18
 
 
19
__all__ = [
 
20
    'xdg_cache_home',
 
21
    'xdg_config_home',
 
22
    ]
 
23
 
18
24
import os
19
25
import sys
20
26
 
21
 
class NotSupportedError(Exception):
22
 
    '''Unsupported platform version.'''
23
 
 
24
 
try:
25
 
    from xdg.BaseDirectory import xdg_config_home, xdg_cache_home
26
 
except ImportError:
27
 
    if sys.platform == 'win32':
28
 
        from bzrlib import win32utils as win
29
 
        xdg_config_home = win.get_appdata_location_unicode()
30
 
        xdg_cache_home = get_temp_location()
31
 
    else:
32
 
        home = os.environ.get('HOME')
33
 
        xdg_config_home = os.path.join(home, '.config/')
34
 
        xdg_cache_home = os.path.join(home, '.cache/')
35
 
 
36
27
 
37
28
# XXX This function should be merged into bzrlib.win32utils
38
29
def get_temp_location():
52
43
 
53
44
    # Not on win32 or nothing found
54
45
    return None
 
46
 
 
47
 
 
48
try:
 
49
    import xdg.BaseDirectory
 
50
except ImportError:
 
51
    if sys.platform == 'win32':
 
52
        from bzrlib import win32utils as win
 
53
        xdg_config_home = win.get_appdata_location_unicode()
 
54
        xdg_cache_home = get_temp_location()
 
55
    else:
 
56
        home = os.environ.get('HOME')
 
57
        xdg_config_home = os.path.join(home, '.config/')
 
58
        xdg_cache_home = os.path.join(home, '.cache/')
 
59
else:
 
60
    xdg_config_home = xdg.BaseDirectory.xdg_config_home
 
61
    xdg_cache_home = xdg.BaseDirectory.xdg_cache_home