You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ariatosca.apache.org by em...@apache.org on 2017/02/07 17:16:06 UTC

incubator-ariatosca git commit: Fix for Windows

Repository: incubator-ariatosca
Updated Branches:
  refs/heads/ARIA-99-e2e-tests a0115d6e6 -> 97b85ae01


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/97b85ae0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/tree/97b85ae0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ariatosca/diff/97b85ae0

Branch: refs/heads/ARIA-99-e2e-tests
Commit: 97b85ae015c1a5b1df48d52b3b48212e9dde004c
Parents: a0115d6
Author: Tal Liron <ta...@gmail.com>
Authored: Tue Feb 7 11:15:58 2017 -0600
Committer: Tal Liron <ta...@gmail.com>
Committed: Tue Feb 7 11:15:58 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/97b85ae0/aria/utils/uris.py
----------------------------------------------------------------------
diff --git a/aria/utils/uris.py b/aria/utils/uris.py
index 1686517..92ec53b 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