From e294cf620aa0dc6e51afa2e54d213ae6526ec5bc Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 29 Jan 1999 18:05:18 +0000 Subject: Add abspath() --- Lib/dospath.py | 7 +++++++ Lib/macpath.py | 7 +++++++ Lib/ntpath.py | 7 +++++++ Lib/posixpath.py | 7 +++++++ 4 files changed, 28 insertions(+) diff --git a/Lib/dospath.py b/Lib/dospath.py index a956c09..d7aa752 100644 --- a/Lib/dospath.py +++ b/Lib/dospath.py @@ -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) diff --git a/Lib/macpath.py b/Lib/macpath.py index 68dd6d4..b19d5a1 100644 --- a/Lib/macpath.py +++ b/Lib/macpath.py @@ -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) diff --git a/Lib/ntpath.py b/Lib/ntpath.py index ca7f3d1..6bab89d 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -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) diff --git a/Lib/posixpath.py b/Lib/posixpath.py index fb3b6a6..36edc80 100644 --- a/Lib/posixpath.py +++ b/Lib/posixpath.py @@ -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) -- cgit v0.12