~ubuntu-app-review-contributors/ubuntu-app-reviews/revision-monitor

« back to all changes in this revision

Viewing changes to revision_monitor/revision_monitorconfig.py

  • Committer: App Bot
  • Author(s): Sasa Stamenkovic
  • Date: 2012-01-31 10:09:54 UTC
  • Revision ID: appbot@holba.ch-20120131100954-mmfr3pmbx1w1egqi
Tags: 1.0-public4
New release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#========================================================================
 
2
# This file is part of Revision Monitor application.
 
3
 
4
# Copyright (C) 2012 Sasa Stamenkovic <umpirsky@gmail.com>
 
5
 
6
# For the full copyright and license information, please view the LICENSE 
 
7
# file that was distributed with this source code.
 
8
#========================================================================
 
9
 
 
10
__all__ = [
 
11
    'project_path_not_found',
 
12
    'get_data_file',
 
13
    'get_data_path',
 
14
    ]
 
15
 
 
16
# Where your project will look for your data (for instance, images and ui
 
17
# files). By default, this is ../data, relative your trunk layout
 
18
__revision_monitor_data_directory__ = '../data/'
 
19
__license__ = 'GPL-3'
 
20
__version__ = '1.0'
 
21
 
 
22
import os
 
23
 
 
24
import gettext
 
25
from gettext import gettext as _
 
26
gettext.textdomain('revision-monitor')
 
27
 
 
28
class project_path_not_found(Exception):
 
29
    """Raised when we can't find the project directory."""
 
30
 
 
31
 
 
32
def get_data_file(*path_segments):
 
33
    """Get the full path to a data file.
 
34
 
 
35
    Returns the path to a file underneath the data directory (as defined by
 
36
    `get_data_path`). Equivalent to os.path.join(get_data_path(),
 
37
    *path_segments).
 
38
    """
 
39
    return os.path.join(get_data_path(), *path_segments)
 
40
 
 
41
 
 
42
def get_data_path():
 
43
    """Retrieve revision-monitor data path
 
44
 
 
45
    This path is by default <revision_monitor_lib_path>/../data/ in trunk
 
46
    and /usr/share/revision-monitor in an installed version but this path
 
47
    is specified at installation time.
 
48
    """
 
49
 
 
50
    # Get pathname absolute or relative.
 
51
    path = os.path.join(
 
52
        os.path.dirname(__file__), __revision_monitor_data_directory__)
 
53
 
 
54
    abs_data_path = os.path.abspath(path)
 
55
    if not os.path.exists(abs_data_path):
 
56
        raise project_path_not_found
 
57
 
 
58
    return abs_data_path
 
59
 
 
60
 
 
61
def get_version():
 
62
    return __version__