~ubuntu-branches/ubuntu/lucid/exaile/lucid

« back to all changes in this revision

Viewing changes to xl/xdg.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2010-02-12 19:51:01 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100212195101-8jt3tculxcl92e6v
Tags: 0.3.1~b1-0ubuntu1
* New upstream release.
* Adjust exaile.install for new plugins.
* debian/control:
 - Drop unneeded python-dev Build-Dep.
 - Bump Standards-Version to 3.8.4 
* debian/rules: No empty po files to delete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008-2009 Adam Olsen 
 
1
# Copyright (C) 2008-2009 Adam Olsen
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
15
15
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
16
#
17
17
#
18
 
# The developers of the Exaile media player hereby grant permission 
19
 
# for non-GPL compatible GStreamer and Exaile plugins to be used and 
20
 
# distributed together with GStreamer and Exaile. This permission is 
21
 
# above and beyond the permissions granted by the GPL license by which 
22
 
# Exaile is covered. If you modify this code, you may extend this 
23
 
# exception to your version of the code, but you are not obligated to 
24
 
# do so. If you do not wish to do so, delete this exception statement 
 
18
# The developers of the Exaile media player hereby grant permission
 
19
# for non-GPL compatible GStreamer and Exaile plugins to be used and
 
20
# distributed together with GStreamer and Exaile. This permission is
 
21
# above and beyond the permissions granted by the GPL license by which
 
22
# Exaile is covered. If you modify this code, you may extend this
 
23
# exception to your version of the code, but you are not obligated to
 
24
# do so. If you do not wish to do so, delete this exception statement
25
25
# from your version.
26
26
 
27
27
import os
52
52
 
53
53
data_dirs = os.getenv("XDG_DATA_DIRS")
54
54
if data_dirs == None:
55
 
    data_dirs = "/usr/local/share/:/usr/share/:/opt/share/"
 
55
    data_dirs = "/usr/local/share/:/usr/share/"
56
56
data_dirs = [os.path.join(d, "exaile") for d in data_dirs.split(":")]
57
57
 
58
58
config_dirs = os.getenv("XDG_CONFIG_DIRS")
61
61
config_dirs = [os.path.join(d, "exaile") for d in config_dirs.split(":")]
62
62
 
63
63
exaile_dir = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
 
64
local_hack = False
64
65
# Detect if Exaile is not installed.
65
66
if os.path.exists(os.path.join(exaile_dir, 'Makefile')):
 
67
    local_hack = True
66
68
    # Insert the "data" directory to data_dirs.
67
69
    data_dir = os.path.join(exaile_dir, 'data')
68
70
    data_dirs.insert(0, data_dir)
69
71
    # insert the config dir
70
72
    config_dir = os.path.join(exaile_dir, 'data', 'config')
71
73
    config_dirs.insert(0, config_dir)
72
 
    # Create a symlink from plugins to data/plugins.
73
 
    plugins_dir = os.path.join(data_dir, 'plugins')
74
 
    if not os.path.exists(plugins_dir):
75
 
        try:
76
 
            os.symlink(os.path.join(exaile_dir, 'plugins'), plugins_dir)
77
 
        except (AttributeError, OSError):
78
 
            # If the system does not support symlinks, ignore.
79
 
            pass
 
74
 
80
75
 
81
76
data_dirs.insert(0, data_home)
82
77
 
86
81
def get_config_dirs():
87
82
    return config_dirs
88
83
 
 
84
def get_data_dir():
 
85
    return data_home
 
86
 
89
87
def get_data_dirs():
90
88
    return data_dirs[:]
91
89
 
94
92
 
95
93
def get_data_path(*subpath_elements):
96
94
    subpath = os.path.join(*subpath_elements)
97
 
    for dir in data_dirs:
98
 
        path = os.path.join(dir, subpath)
 
95
    for d in data_dirs:
 
96
        path = os.path.join(d, subpath)
99
97
        if os.path.exists(path):
100
98
            return path
101
99
    return None
102
100
 
103
101
def get_config_path(*subpath_elements):
104
102
    subpath = os.path.join(*subpath_elements)
105
 
    for dir in config_dirs:
106
 
        path = os.path.join(dir, subpath)
 
103
    for d in config_dirs:
 
104
        path = os.path.join(d, subpath)
107
105
        if os.path.exists(path):
108
106
            return path
109
107
    return None