Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-99-e2e-tests 90612731f -> 344e3caa9 (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/344e3caa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/344e3caa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/344e3caa

Branch: refs/heads/ARIA-99-e2e-tests
Commit: 344e3caa9aa7f9430626b9bf83084aa7decad280
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 21:17:09 2017 -0600

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


http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/blob/344e3caa/aria/utils/uris.py
----------------------------------------------------------------------
diff --git a/aria/utils/uris.py b/aria/utils/uris.py
index 1686517..8c531f7 100644
--- a/aria/utils/uris.py
+++ b/aria/utils/uris.py
@@ -16,13 +16,26 @@
 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:
+        # 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
+        path = uri.replace('/', os.path.sep)
+        if os.path.exists(path):
+            return os.path.normpath(path)
+
     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