~fioan89/slidewall/slidewall

« back to all changes in this revision

Viewing changes to slidewall_lib/helpers.py

  • Committer: Faur Ioan-Aurel
  • Date: 2012-10-26 19:12:18 UTC
  • Revision ID: fioan89@gmail.com-20121026191218-hz96j103887xecjc
commit before release

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
import logging
19
19
import os
20
20
 
21
 
from . slidewallconfig import get_data_file
22
 
from . Builder import Builder
 
21
from .slidewallconfig import get_data_file
 
22
from .Builder import Builder
23
23
 
24
24
import gettext
25
25
from gettext import gettext as _
 
26
 
26
27
gettext.textdomain('slidewall')
27
28
 
28
29
def get_builder(builder_file_name):
49
50
    if not os.path.exists(media_filename):
50
51
        media_filename = None
51
52
 
52
 
    return "file:///"+media_filename
 
53
    return "file:///" + media_filename
 
54
 
53
55
 
54
56
class NullHandler(logging.Handler):
55
57
    def emit(self, record):
56
58
        pass
57
59
 
 
60
 
58
61
def set_up_logging(opts):
59
62
    # add a handler to prevent basicConfig
60
63
    root = logging.getLogger()
80
83
    if opts.verbose > 1:
81
84
        lib_logger.setLevel(logging.DEBUG)
82
85
 
 
86
 
83
87
def get_help_uri(page=None):
84
88
    # help_uri from source tree - default language
85
89
    here = os.path.dirname(__file__)
95
99
 
96
100
    return help_uri
97
101
 
 
102
 
98
103
def show_uri(parent, link):
99
104
    from gi.repository import Gtk # pylint: disable=E0611
 
105
 
100
106
    screen = parent.get_screen()
101
107
    Gtk.show_uri(screen, link, Gtk.get_current_event_time())
102
108
 
 
109
 
103
110
def alias(alternative_function_name):
104
111
    '''see http://www.drdobbs.com/web-development/184406073#l9'''
 
112
 
105
113
    def decorator(function):
106
114
        '''attach alternative_function_name(s) to function'''
107
115
        if not hasattr(function, 'aliases'):
108
116
            function.aliases = []
109
117
        function.aliases.append(alternative_function_name)
110
118
        return function
 
119
 
111
120
    return decorator