Utilities/__init__.py

changeset 5708
9b01b4004314
parent 5696
68af0e9c57ad
child 5726
e1dbd217214a
--- a/Utilities/__init__.py	Tue Apr 18 19:22:54 2017 +0200
+++ b/Utilities/__init__.py	Wed Apr 19 19:02:34 2017 +0200
@@ -1037,6 +1037,24 @@
     @return flag indicating executable status (boolean)
     """
     return os.access(exe, os.X_OK)
+
+
+def isDrive(path):
+    """
+    Function to check, if a path is a Windows drive.
+    
+    @param path path name to be checked
+    @type str
+    @return flag indicating a Windows drive
+    @rtype bool
+    """
+    isDrive = False
+    drive, directory = os.path.splitdrive(path)
+    if drive and len(drive) == 2 and drive.endswith(":") and \
+       directory in ["", "\\", "/"]:
+        isDrive = True
+    
+    return isDrive
     
 
 def samepath(f1, f2):

eric ide

mercurial