1
# Miro - an RSS based video player application
2
# Copyright (C) 2005-2010 Participatory Culture Foundation
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
# In addition, as a special exception, the copyright holders give
19
# permission to link the code of portions of this program with the OpenSSL
22
# You must obey the GNU General Public License in all respects for all of
23
# the code used other than OpenSSL. If you modify file(s) with this
24
# exception, you may extend this exception to your version of the file(s),
25
# but you are not obligated to do so. If you do not wish to do so, delete
26
# this exception statement from your version. If you delete this exception
27
# statement from all source files in the program, then also delete it here.
35
from miro.plat import specialfolders
38
"""Determine the directory the .exe file is located in. Taken from the
39
WhereAmI recipe on the py2exe website.
41
exe_path = unicode(sys.executable, sys.getfilesystemencoding())
42
return os.path.dirname(exe_path)
45
return os.path.join(appRoot(), 'resources')
48
return os.path.join(root(), path)
50
# Note: some of these functions are probably not absolutely correct in
51
# the face of funny characters in the input paths. In particular,
52
# url() doesn't DTRT when the path contains spaces. But they should be
53
# sufficient for resolving resources, since we have control over the
56
# Find the full path to a resource data file. 'relative_path' is
57
# expected to be supplied in Unix format, with forward-slashes as
58
# separators. The output, though, uses the native platform separator.
59
def path(relative_path):
60
abspath = os.path.abspath(os.path.join(root(), relative_path))
61
return abspath.replace("/", "\\")
63
def url(relative_path):
64
return absoluteUrl(path(relative_path))
66
def absoluteUrl(absolute_path):
67
"""Like url, but without adding the resource directory.
69
absolute_path = absolute_path.encode('utf_8')
70
return u"file:///" + urllib.quote(absolute_path, safe=":~\\")
72
def _getThemeDirectory():
73
# We don't get the publisher and long app name from the config so
74
# changing the app name doesn't change the support directory
75
path = os.path.join(specialfolders.commonAppDataDirectory,
76
u'Participatory Culture Foundation',
85
def theme_path(theme, relative_path):
86
return os.path.join(_getThemeDirectory(), theme, relative_path)
89
osname = '%s %s %s' % (platform.system(), platform.release(),
93
def get_default_search_dir():
94
return specialfolders.get_special_folder("My Videos")