frontends: define the constants with classes and inheritance instance of using __builtin__
This commit is contained in:
parent
b824f9c2ce
commit
f5dd3f2265
1 changed files with 169 additions and 95 deletions
|
|
@ -19,15 +19,16 @@
|
|||
|
||||
from sat.tools.jid import JID
|
||||
from os.path import exists, splitext
|
||||
from sat_frontends.quick_frontend.constants import Const
|
||||
|
||||
def escapePrivate(ori_jid):
|
||||
"""Escape a private jid"""
|
||||
return JID(const_PRIVATE_PREFIX + ori_jid.bare + '@' + ori_jid.resource)
|
||||
return JID(Const.PRIVATE_PREFIX + ori_jid.bare + '@' + ori_jid.resource)
|
||||
|
||||
def unescapePrivate(escaped_jid):
|
||||
if not escaped_jid.startswith(const_PRIVATE_PREFIX):
|
||||
if not escaped_jid.startswith(Const.PRIVATE_PREFIX):
|
||||
return escaped_jid
|
||||
escaped_split = tuple(escaped_jid[len(const_PRIVATE_PREFIX):].split('@'))
|
||||
escaped_split = tuple(escaped_jid[len(Const.PRIVATE_PREFIX):].split('@'))
|
||||
assert(len(escaped_split) == 3)
|
||||
return JID("%s@%s/%s" % escaped_split)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue