comparison frontends/src/constants.py @ 737:378af36155c2

frontends: set and retrieve your own presence and status
author souliane <souliane@mailoo.org>
date Mon, 25 Nov 2013 01:56:07 +0100
parents 6246eb6d64a0
children 312a2842b2b8
comparison
equal deleted inserted replaced
736:6246eb6d64a0 737:378af36155c2
21 try: 21 try:
22 _("dummy") 22 _("dummy")
23 except: # libervia doesn't allow to explicit the exception here 23 except: # libervia doesn't allow to explicit the exception here
24 _ = lambda text: text 24 _ = lambda text: text
25 25
26 try:
27 from collections import OrderedDict # only available from python 2.7
28 except ImportError:
29 try:
30 from ordereddict import OrderedDict
31 except ImportError:
32 pass # libervia can not import external libraries
33
34
35 def getPresence():
36 """We cannot do it directly in the Const class, if it is not encapsulated
37 in a method we get a JS runtime SyntaxError: "missing ) in parenthetical".
38 # TODO: merge this definition with those in primitivus.constants and wix.constants
39 """
40 try:
41 presence = OrderedDict([("", _("Online")),
42 ("chat", _("Free for chat")),
43 ("away", _("Away from keyboard")),
44 ("dnd", _("Do not disturb")),
45 ("xa", _("Away"))])
46 except TypeError:
47 presence = {"": _("Online"),
48 "chat": _("Free for chat"),
49 "away": _("Away from keyboard"),
50 "dnd": _("Do not disturb"),
51 "xa": _("Away")
52 }
53 return presence
54
55
26 class Const(object): 56 class Const(object):
27 57 PRESENCE = getPresence()
28 # TODO: find a way to merge it with the ones of primitivus and wix
29 PRESENCE = {"": _("Online"),
30 "chat": _("Free for chat"),
31 "away": _("Away from keyboard"),
32 "dnd": _("Do not disturb"),
33 "xa": _("Away")
34 }