Module: deluge
Branch: master
Commit: dd8400558c20f8d30ffe0b81da0aac1847e5c632

Author: Damien Churchill <[email protected]>
Date:   Sun Mar 28 12:14:53 2010 +0100

use a platform agnostic way of combining paths in the FileTree

---

 deluge/common.py    |   18 ++++++++++++++++++
 deluge/ui/common.py |    4 ++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/deluge/common.py b/deluge/common.py
index ab25b24..fce4052 100644
--- a/deluge/common.py
+++ b/deluge/common.py
@@ -514,6 +514,24 @@ def is_ip(ip):
     except socket.error:
         return False
 
+def path_join(*parts):
+    """
+    An implementation of os.path.join that always uses / for the separator
+    to ensure that the correct paths are produced when working with internal
+    paths on Windows.
+    """
+    path = ''
+    for part in parts:
+        if not part:
+            continue
+        elif part[0] == '/':
+            path = part
+        elif not path:
+            path = part
+        else:
+            path += '/' + part
+    return path
+
 class VersionSplit(object):
     """
     Used for comparing version numbers.
diff --git a/deluge/ui/common.py b/deluge/ui/common.py
index 8acefd0..3287230 100644
--- a/deluge/ui/common.py
+++ b/deluge/ui/common.py
@@ -49,7 +49,7 @@ try:
 except ImportError:
     from sha import sha
 
-from deluge import bencode
+from deluge import bencode, common
 from deluge.log import LOG as log
 import deluge.configmanager
 
@@ -289,7 +289,7 @@ class FileTree2(object):
         """
         def walk(directory, parent_path):
             for path in directory["contents"].keys():
-                full_path = os.path.join(parent_path, path)
+                full_path = common.path_join(parent_path, path)
                 if directory["contents"][path]["type"] == "dir":
                     directory["contents"][path] = callback(full_path, 
directory["contents"][path]) or \
                              directory["contents"][path]

-- 
You received this message because you are subscribed to the Google Groups 
"deluge-commit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/deluge-commit?hl=en.

Reply via email to