~dpm/qreator/snap

« back to all changes in this revision

Viewing changes to build/lib.linux-x86_64-2.7/qreator_lib/qreatorconfig.py

  • Committer: David Planella
  • Date: 2012-05-18 11:20:02 UTC
  • Revision ID: david.planella@ubuntu.com-20120518112002-bmx57p0x2x14xr9n
Added Python file to avoid intltool failing to find it during build. Will need to investigate more

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
 
### BEGIN LICENSE
3
 
# Copyright (C) 2012 David Planella <david.planella@ubuntu.com>
4
 
# Copyright (C) 2012 Michael Hall <mhall119@ubuntu.com>
5
 
# This program is free software: you can redistribute it and/or modify it 
6
 
# under the terms of the GNU General Public License version 3, as published 
7
 
# by the Free Software Foundation.
8
 
9
 
# This program is distributed in the hope that it will be useful, but 
10
 
# WITHOUT ANY WARRANTY; without even the implied warranties of 
11
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
12
 
# PURPOSE.  See the GNU General Public License for more details.
13
 
14
 
# You should have received a copy of the GNU General Public License along 
15
 
# with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
### END LICENSE
17
 
 
18
 
# THIS IS Qreator CONFIGURATION FILE
19
 
# YOU CAN PUT THERE SOME GLOBAL VALUE
20
 
# Do not touch unless you know what you're doing.
21
 
# you're warned :)
22
 
 
23
 
__all__ = [
24
 
    'project_path_not_found',
25
 
    'get_data_file',
26
 
    'get_data_path',
27
 
    ]
28
 
 
29
 
# Where your project will look for your data (for instance, images and ui
30
 
# files). By default, this is ../data, relative your trunk layout
31
 
__qreator_data_directory__ = '../data/'
32
 
__license__ = 'GPL-3'
33
 
__version__ = 'VERSION'
34
 
 
35
 
import os
36
 
 
37
 
import gettext
38
 
from gettext import gettext as _
39
 
gettext.textdomain('qreator')
40
 
 
41
 
class project_path_not_found(Exception):
42
 
    """Raised when we can't find the project directory."""
43
 
 
44
 
 
45
 
def get_data_file(*path_segments):
46
 
    """Get the full path to a data file.
47
 
 
48
 
    Returns the path to a file underneath the data directory (as defined by
49
 
    `get_data_path`). Equivalent to os.path.join(get_data_path(),
50
 
    *path_segments).
51
 
    """
52
 
    return os.path.join(get_data_path(), *path_segments)
53
 
 
54
 
 
55
 
def get_data_path():
56
 
    """Retrieve qreator data path
57
 
 
58
 
    This path is by default <qreator_lib_path>/../data/ in trunk
59
 
    and /usr/share/qreator in an installed version but this path
60
 
    is specified at installation time.
61
 
    """
62
 
 
63
 
    # Get pathname absolute or relative.
64
 
    path = os.path.join(
65
 
        os.path.dirname(__file__), __qreator_data_directory__)
66
 
 
67
 
    abs_data_path = os.path.abspath(path)
68
 
    if not os.path.exists(abs_data_path):
69
 
        raise project_path_not_found
70
 
 
71
 
    return abs_data_path
72
 
 
73
 
 
74
 
def get_version():
75
 
    return __version__