diff 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
line wrap: on
line diff
--- a/frontends/src/quick_frontend/quick_utils.py	Wed Nov 14 20:24:28 2012 +0100
+++ b/frontends/src/quick_frontend/quick_utils.py	Wed Nov 14 20:37:15 2012 +0100
@@ -20,6 +20,7 @@
 """
 
 from sat.tools.jid  import JID
+from os.path import exists, splitext
 
 def escapePrivate(ori_jid):
     """Escape a private jid"""
@@ -31,3 +32,16 @@
     escaped_split = tuple(escaped_jid[len(const_PRIVATE_PREFIX):].split('@'))
     assert(len(escaped_split) == 3)
     return JID("%s@%s/%s" % escaped_split)
+
+def getNewPath(path):
+    """ Check if path exists, and find a non existant path if needed """
+    idx = 2
+    if not exists(path):
+        return path
+    root, ext = splitext(path)
+    while True:
+        new_path = "%s_%d%s" % (root, idx, ext)
+        if not exists(new_path):
+            return new_path
+        idx+=1
+