public
Description: Web-based translation and translation management tool
Homepage: http://translate.sf.net/
Clone URL: git://github.com/julen/pootle.git
pootle / filelocations.py
100644 49 lines (41 sloc) 1.756 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: utf-8 -*-
#
# Copyright 2005 Zuza Software Foundation
#
# This file is part of translate.
#
# translate is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# translate is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with translate; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
"""module to handle consistent file locations for Pootle"""
 
import os.path
import sys
import imp
 
def check_if_frozen():
    return (hasattr(sys, "frozen") or # new py2exe
            hasattr(sys, "importers") # old py2exe
            or imp.is_frozen("__main__")) # tools/freeze
 
is_frozen = check_if_frozen()
# same directory as this file (or the executable under py2exe)
if is_frozen:
  pootledir = os.path.abspath(os.path.dirname(sys.executable))
  jtoolkitdir = os.path.abspath(os.path.dirname(sys.executable))
else:
  from jToolkit import __version__ as jtoolkitversion
  pootledir = os.path.abspath(os.path.dirname(__file__))
  jtoolkitdir = os.path.dirname(jtoolkitversion.__file__)
 
# default prefs file is pootle.prefs in the pootledir
prefsfile = os.path.join(pootledir, 'pootle.prefs')
 
htmldir = os.path.join(pootledir, "html")
templatedir = os.path.join(pootledir, "templates")
sys.path.append(templatedir) # So kid can find our templates