AutoTimer: StartUp delay can be configured within the global AutoTimer settings.
[enigma2-plugins.git] / autotimer / src / __init__.py
1 # -*- coding: utf-8 -*-
2 from Components.Language import language
3 from Tools.Directories import resolveFilename, SCOPE_PLUGINS, SCOPE_LANGUAGE
4 from os import environ as os_environ
5 import gettext
6
7 # Config
8 from Components.config import config, ConfigSubsection, ConfigEnableDisable, \
9         ConfigNumber, ConfigSelection, ConfigYesNo
10
11 config.plugins.autotimer = ConfigSubsection()
12 config.plugins.autotimer.autopoll = ConfigEnableDisable(default=False)
13 config.plugins.autotimer.delay = ConfigNumber(default=3)
14 config.plugins.autotimer.interval = ConfigNumber(default=3)
15 config.plugins.autotimer.refresh = ConfigSelection(choices=[
16                 ("none", _("None")),
17                 ("auto", _("Only AutoTimers created during this session")),
18                 ("all", _("All non-repeating timers"))
19         ], default="none"
20 )
21 config.plugins.autotimer.try_guessing = ConfigEnableDisable(default=True)
22 config.plugins.autotimer.editor = ConfigSelection(choices=[
23                 ("plain", _("Classic")),
24                 ("wizard", _("Wizard"))
25         ], default="wizard"
26 )
27 config.plugins.autotimer.addsimilar_on_conflict = ConfigEnableDisable(default=False)
28 config.plugins.autotimer.add_autotimer_to_tags = ConfigYesNo(default=False)
29 config.plugins.autotimer.add_name_to_tags = ConfigYesNo(default=False)
30 config.plugins.autotimer.disabled_on_conflict = ConfigEnableDisable(default=False)
31 config.plugins.autotimer.show_in_extensionsmenu = ConfigYesNo(default=False)
32 config.plugins.autotimer.fastscan = ConfigYesNo(default=False)
33 config.plugins.autotimer.notifconflict = ConfigYesNo(default=True)
34 config.plugins.autotimer.notifsimilar = ConfigYesNo(default=True)
35 config.plugins.autotimer.maxdaysinfuture = ConfigNumber(default=0)
36 config.plugins.autotimer.show_help = ConfigYesNo(default=True)
37 config.plugins.autotimer.skip_during_records = ConfigYesNo(default=False)
38
39 def localeInit():
40         lang = language.getLanguage()[:2] # getLanguage returns e.g. "fi_FI" for "language_country"
41         os_environ["LANGUAGE"] = lang # Enigma doesn't set this (or LC_ALL, LC_MESSAGES, LANG). gettext needs it!
42         gettext.bindtextdomain("AutoTimer", resolveFilename(SCOPE_PLUGINS, "Extensions/AutoTimer/locale"))
43
44 def _(txt):
45         t = gettext.dgettext("AutoTimer", txt)
46         if t == txt:
47                 t = gettext.gettext(txt)
48         return t
49
50 localeInit()
51 language.addCallback(localeInit)
52
53 try:
54         xrange = xrange
55         iteritems = lambda d: d.iteritems()
56         itervalues = lambda d: d.itervalues()
57 except NameError:
58         xrange = range
59         iteritems = lambda d: d.items()
60         itervalues = lambda d: d.values()
61
62 __all__ = ['_', 'config', 'iteritems', 'itervalues', 'xrange']