~dpm/qreator/snap

« back to all changes in this revision

Viewing changes to qreator_lib/helpers.py

  • Committer: Stefan Schwarzburg
  • Date: 2012-06-15 09:00:00 UTC
  • Revision ID: stefan.schwarzburg@googlemail.com-20120615090000-ht2fkoiv76xiiesi
Sprite saving location moved to $XDG_CACHE_HOME/qreator/.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2
2
### BEGIN LICENSE
3
3
# Copyright (C) 2012 David Planella <david.planella@ubuntu.com>
4
 
# This program is free software: you can redistribute it and/or modify it 
5
 
# under the terms of the GNU General Public License version 3, as published 
 
4
# This program is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License version 3, as published
6
6
# by the Free Software Foundation.
7
 
8
 
# This program is distributed in the hope that it will be useful, but 
9
 
# WITHOUT ANY WARRANTY; without even the implied warranties of 
10
 
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR 
 
7
#
 
8
# This program is distributed in the hope that it will be useful, but
 
9
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
11
# PURPOSE.  See the GNU General Public License for more details.
12
 
13
 
# You should have received a copy of the GNU General Public License along 
 
12
#
 
13
# You should have received a copy of the GNU General Public License along
14
14
# with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
### END LICENSE
16
16
 
17
17
"""Helpers for an Ubuntu application."""
18
18
import logging
19
19
import os
 
20
import xdg
20
21
 
21
22
from . qreatorconfig import get_data_file
22
23
from . Builder import Builder
23
24
 
24
25
 
25
26
def get_builder(builder_file_name):
26
 
    """Return a fully-instantiated Gtk.Builder instance from specified ui 
 
27
    """Return a fully-instantiated Gtk.Builder instance from specified ui
27
28
    file
28
29
 
29
30
    :param builder_file_name: The name of the builder file, without extension.
49
50
    return media_filename
50
51
 
51
52
 
 
53
def get_cache_file(file_name):
 
54
    path = os.path.join(xdg.BaseDirectory.xdg_cache_home, 'qreator', file_name)
 
55
    if not os.path.exists(path):
 
56
        os.makedirs(path)
 
57
    return path
 
58
 
 
59
 
52
60
class NullHandler(logging.Handler):
53
61
    def emit(self, record):
54
62
        pass