Mercurial > libervia-backend
comparison frontends/src/quick_frontend/quick_utils.py @ 736:6246eb6d64a0
frontends: define the constants with classes and inheritance instance of using __builtin__
author | souliane <souliane@mailoo.org> |
---|---|
date | Sat, 23 Nov 2013 10:21:40 +0100 |
parents | f7878ad3c846 |
children | 1fe00f0c9a91 |
comparison
equal
deleted
inserted
replaced
735:682933ca304c | 736:6246eb6d64a0 |
---|---|
17 # You should have received a copy of the GNU Affero General Public License | 17 # You should have received a copy of the GNU Affero General Public License |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 from sat.tools.jid import JID | 20 from sat.tools.jid import JID |
21 from os.path import exists, splitext | 21 from os.path import exists, splitext |
22 from sat_frontends.quick_frontend.constants import Const | |
22 | 23 |
23 def escapePrivate(ori_jid): | 24 def escapePrivate(ori_jid): |
24 """Escape a private jid""" | 25 """Escape a private jid""" |
25 return JID(const_PRIVATE_PREFIX + ori_jid.bare + '@' + ori_jid.resource) | 26 return JID(Const.PRIVATE_PREFIX + ori_jid.bare + '@' + ori_jid.resource) |
26 | 27 |
27 def unescapePrivate(escaped_jid): | 28 def unescapePrivate(escaped_jid): |
28 if not escaped_jid.startswith(const_PRIVATE_PREFIX): | 29 if not escaped_jid.startswith(Const.PRIVATE_PREFIX): |
29 return escaped_jid | 30 return escaped_jid |
30 escaped_split = tuple(escaped_jid[len(const_PRIVATE_PREFIX):].split('@')) | 31 escaped_split = tuple(escaped_jid[len(Const.PRIVATE_PREFIX):].split('@')) |
31 assert(len(escaped_split) == 3) | 32 assert(len(escaped_split) == 3) |
32 return JID("%s@%s/%s" % escaped_split) | 33 return JID("%s@%s/%s" % escaped_split) |
33 | 34 |
34 def getNewPath(path): | 35 def getNewPath(path): |
35 """ Check if path exists, and find a non existant path if needed """ | 36 """ Check if path exists, and find a non existant path if needed """ |