Author: jprantan
Date: Thu Apr  9 05:12:42 2009
New Revision: 1774

Modified:
   trunk/src/robot/utils/normalizing.py

Log:
Fixed normpath to work in Windows with Jython when path is X:\. Earlier returned x: instead of x:\.

Modified: trunk/src/robot/utils/normalizing.py
==============================================================================
--- trunk/src/robot/utils/normalizing.py        (original)
+++ trunk/src/robot/utils/normalizing.py        Thu Apr  9 05:12:42 2009
@@ -57,14 +57,22 @@
     On case-insensitive file systems the path is also casenormalized
     (if normcase is True).
     """
-    if os.sep == '\\' and len(path) == 2 and path[1] == ':':
-        path = path + '\\'
-    else:
-        path = os.path.abspath(path)
+    path = _abspath(path)
     if normcase and _CASE_INSENSITIVE_FILESYSTEM:
         path = path.lower()
     return path

+def _abspath(path):
+    pathlen = len(path)
+    # Return 'x:\' both when the given path is 'x:\' and 'x:'. Notice that
+ # os.path.abspath('x:') returns the current dir (we don't want that) and + # with Jython os.path.abspath('x:\') returns 'x:' (don't want that either)
+    if os.sep == '\\' and pathlen > 1 and path[1] == ':':
+        if pathlen == 2:
+            return path + '\\'
+        if pathlen == 3:
+            return path
+    return os.path.abspath(path)

 class NormalizedDict(UserDict):

Reply via email to