Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-99-e2e-tests 97b85ae01 -> 90612731f (forced update)


Fix for Windows


Project: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/commit/90612731
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/90612731
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/90612731

Branch: refs/heads/ARIA-99-e2e-tests
Commit: 90612731ff20720700fa68d46f6d6f7ac13ae6e3
Parents: a0115d6
Author: Tal Liron <[email protected]>
Authored: Tue Feb 7 11:15:58 2017 -0600
Committer: Tal Liron <[email protected]>
Committed: Tue Feb 7 15:08:41 2017 -0600

----------------------------------------------------------------------
 aria/utils/uris.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/90612731/aria/utils/uris.py
----------------------------------------------------------------------
diff --git a/aria/utils/uris.py b/aria/utils/uris.py
index 1686517..5834bca 100644
--- a/aria/utils/uris.py
+++ b/aria/utils/uris.py
@@ -16,13 +16,24 @@
 import os
 import urlparse
 
+
+_IS_WINDOWS = (os.name == 'nt')
+
+
 def as_file(uri):
     """
-    If the URI is a file (either the :code:`file` scheme or no scheme), then 
returns the absolute
+    If the URI is a file (either the :code:`file` scheme or no scheme), then 
returns the normalized
     path. Otherwise, returns None.
     """
 
+    if _IS_WINDOWS and os.path.exists(uri):
+        # We need this extra check in Windows because paths might have a drive 
prefix, e.g. "C:",
+        # which will be considered a scheme for urlparse
+        return uri
+
     url = urlparse.urlparse(uri)
-    if (not url.scheme) or (url.scheme == 'file'):
-        return os.path.abspath(url.path)
+    scheme = url.scheme
+    if (not scheme) or (scheme == 'file'):
+        return os.path.normpath(url.path)
+
     return None

Reply via email to