~ubuntu-branches/ubuntu/saucy/unity-tweak-tool/saucy-proposed

« back to all changes in this revision

Viewing changes to UnityTweakTool/config/data.py

  • Committer: Package Import Robot
  • Author(s): Barneedhar Vigneshwar
  • Date: 2013-02-15 20:33:41 UTC
  • Revision ID: package-import@ubuntu.com-20130215203341-yqrfr9df488k41am
Tags: 0.0.3
* New upstream release
* Closes needs-packaging bug (LP: #1126433)

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
#
 
3
# Team:
 
4
#   J Phani Mahesh <phanimahesh@gmail.com>
 
5
#   Barneedhar (jokerdino) <barneedhar@ubuntu.com>
 
6
#   Amith KK <amithkumaran@gmail.com>
 
7
#   Georgi Karavasilev <motorslav@gmail.com>
 
8
#   Sam Tran <samvtran@gmail.com>
 
9
#   Sam Hewitt <hewittsamuel@gmail.com>
 
10
#   Angel Araya <al.arayaq@gmail.com>
 
11
#
 
12
# Description:
 
13
#   A One-stop configuration tool for Unity.
 
14
#
 
15
# Legal Stuff:
 
16
#
 
17
# This file is a part of Unity Tweak Tool
 
18
#
 
19
# Unity Tweak Tool is free software; you can redistribute it and/or modify it under
 
20
# the terms of the GNU General Public License as published by the Free Software
 
21
# Foundation; version 3.
 
22
#
 
23
# Unity Tweak Tool is distributed in the hope that it will be useful, but WITHOUT
 
24
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
25
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
 
26
# details.
 
27
#
 
28
# You should have received a copy of the GNU General Public License along with
 
29
# this program; if not, see <https://www.gnu.org/licenses/gpl-3.0.txt>
 
30
 
 
31
__all__ = [
 
32
    'project_path_not_found',
 
33
    'get_data_file',
 
34
    'get_data_path',
 
35
    ]
 
36
 
 
37
# Where your project will look for your data (for instance, images and ui
 
38
# files). By default, this is ../data, relative your trunk layout
 
39
__unity_tweak_tool_data_directory__ = '../../data/'
 
40
__license__ = 'GPL-3'
 
41
__version__ = '0.0.3'
 
42
 
 
43
import os
 
44
 
 
45
from locale import gettext as _
 
46
 
 
47
class project_path_not_found(Exception):
 
48
    """Raised when we can't find the project directory."""
 
49
 
 
50
 
 
51
def get_data_file(*path_segments):
 
52
    """Get the full path to a data file.
 
53
 
 
54
    Returns the path to a file underneath the data directory (as defined by
 
55
    `get_data_path`). Equivalent to os.path.join(get_data_path(),
 
56
    *path_segments).
 
57
    """
 
58
    return os.path.join(get_data_path(), *path_segments)
 
59
 
 
60
 
 
61
def get_data_path():
 
62
    """Retrieve unity-tweak-tool data path"""
 
63
 
 
64
    # Get pathname absolute or relative.
 
65
    path = os.path.join(
 
66
        os.path.dirname(__file__), __unity_tweak_tool_data_directory__)
 
67
 
 
68
    abs_data_path = os.path.abspath(path)
 
69
    if not os.path.exists(abs_data_path):
 
70
        raise project_path_not_found
 
71
 
 
72
    return abs_data_path
 
73
 
 
74
def get_version():
 
75
    return __version__