comparison frontends/src/quick_frontend/quick_utils.py @ 542:3eeb6c865e4d

frontends: incoming files transfer management: - quick app: getWaitingConf is used on profile connexion - primitivus: askConfirmation is now managed, use new 'dir' style of FileDialog
author Goffi <goffi@goffi.org>
date Wed, 14 Nov 2012 20:37:15 +0100
parents 886754295efe
children ca13633d3b6b
comparison
equal deleted inserted replaced
541:8b116fa42a31 542:3eeb6c865e4d
18 You should have received a copy of the GNU Affero General Public License 18 You should have received a copy of the GNU Affero General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>. 19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 """ 20 """
21 21
22 from sat.tools.jid import JID 22 from sat.tools.jid import JID
23 from os.path import exists, splitext
23 24
24 def escapePrivate(ori_jid): 25 def escapePrivate(ori_jid):
25 """Escape a private jid""" 26 """Escape a private jid"""
26 return JID(const_PRIVATE_PREFIX + ori_jid.short + '@' + ori_jid.resource) 27 return JID(const_PRIVATE_PREFIX + ori_jid.short + '@' + ori_jid.resource)
27 28
29 if not escaped_jid.startswith(const_PRIVATE_PREFIX): 30 if not escaped_jid.startswith(const_PRIVATE_PREFIX):
30 return escaped_jid 31 return escaped_jid
31 escaped_split = tuple(escaped_jid[len(const_PRIVATE_PREFIX):].split('@')) 32 escaped_split = tuple(escaped_jid[len(const_PRIVATE_PREFIX):].split('@'))
32 assert(len(escaped_split) == 3) 33 assert(len(escaped_split) == 3)
33 return JID("%s@%s/%s" % escaped_split) 34 return JID("%s@%s/%s" % escaped_split)
35
36 def getNewPath(path):
37 """ Check if path exists, and find a non existant path if needed """
38 idx = 2
39 if not exists(path):
40 return path
41 root, ext = splitext(path)
42 while True:
43 new_path = "%s_%d%s" % (root, idx, ext)
44 if not exists(new_path):
45 return new_path
46 idx+=1
47