Simplify portage.normalize_path() logic.
authorZac Medico <zmedico@gentoo.org>
Sat, 15 Jul 2006 18:34:08 +0000 (18:34 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 15 Jul 2006 18:34:08 +0000 (18:34 -0000)
svn path=/main/trunk/; revision=3889

pym/portage.py

index 00f6a427fefbb7d356f1a41040bc1aadf17c8d6b..a50b573daefe60e68c9a9e0d66ad23059f317a6a 100644 (file)
@@ -188,11 +188,11 @@ def prefix_array(array,prefix,doblanks=1):
        return newarray
 
 def normalize_path(mypath):
-       newpath = os.path.normpath(mypath)
-       if len(newpath) > 1:
-               if newpath[:2] == "//":
-                       newpath = newpath[1:]
-       return newpath
+       if mypath.startswith(os.path.sep):
+               # posixpath.normpath collapses 3 or more leading slashes to just 1.
+               return os.path.normpath(2*os.path.sep + mypath)
+       else:
+               return os.path.normpath(mypath)
 
 dircache = {}
 cacheHit=0