]> granicus.if.org Git - python/commitdiff
Add abspath()
authorGuido van Rossum <guido@python.org>
Fri, 29 Jan 1999 18:05:18 +0000 (18:05 +0000)
committerGuido van Rossum <guido@python.org>
Fri, 29 Jan 1999 18:05:18 +0000 (18:05 +0000)
Lib/dospath.py
Lib/macpath.py
Lib/ntpath.py
Lib/posixpath.py

index a956c09269c989ab6f708e4b4fd7fcf4a23dacd3..d7aa75246c2ef1fd3b7b339483095cdb3ebef7f3 100644 (file)
@@ -332,3 +332,10 @@ def normpath(path):
                comps.append('.')
        return prefix + string.joinfields(comps, os.sep)
 
+
+
+# Return an absolute path.
+def abspath(path):
+    if not isabs(path):
+        path = join(os.getcwd(), path)
+    return normpath(path)
index 68dd6d48cc1389e992e05c6b405d2aba731d2344..b19d5a1f660e653b52252d6dbf3cf9e5ee3811de 100644 (file)
@@ -212,3 +212,10 @@ def walk(top, func, arg):
                name = join(top, name)
                if isdir(name):
                        walk(name, func, arg)
+
+
+# Return an absolute path.
+def abspath(path):
+    if not isabs(path):
+        path = join(os.getcwd(), path)
+    return normpath(path)
index ca7f3d105669e5d83b7e8a3db5c86940b7f4bb58..6bab89dddf63b79c525519c5569f435844cbba30 100644 (file)
@@ -365,3 +365,10 @@ def normpath(path):
     if not prefix and not comps:
         comps.append('.')
     return prefix + string.joinfields(comps, os.sep)
+
+
+# Return an absolute path.
+def abspath(path):
+    if not isabs(path):
+        path = join(os.getcwd(), path)
+    return normpath(path)
index fb3b6a64f987638facd72da654d7ce4db5f61dcf..36edc80f1400eef0560b2302b457d87fc0f33261 100644 (file)
@@ -367,3 +367,10 @@ def normpath(path):
     if not comps and not slashes:
         comps.append('.')
     return slashes + string.joinfields(comps, '/')
+
+
+# Return an absolute path.
+def abspath(path):
+    if not isabs(path):
+        path = join(os.getcwd(), path)
+    return normpath(path)