Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e294cf6

Browse files
committed
Add abspath()
1 parent 1804dc3 commit e294cf6

4 files changed

Lines changed: 28 additions & 0 deletions

File tree

Lib/dospath.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,3 +332,10 @@ def normpath(path):
332332
comps.append('.')
333333
return prefix + string.joinfields(comps, os.sep)
334334

335+
336+
337+
# Return an absolute path.
338+
def abspath(path):
339+
if not isabs(path):
340+
path = join(os.getcwd(), path)
341+
return normpath(path)

Lib/macpath.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,10 @@ def walk(top, func, arg):
212212
name = join(top, name)
213213
if isdir(name):
214214
walk(name, func, arg)
215+
216+
217+
# Return an absolute path.
218+
def abspath(path):
219+
if not isabs(path):
220+
path = join(os.getcwd(), path)
221+
return normpath(path)

Lib/ntpath.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,10 @@ def normpath(path):
365365
if not prefix and not comps:
366366
comps.append('.')
367367
return prefix + string.joinfields(comps, os.sep)
368+
369+
370+
# Return an absolute path.
371+
def abspath(path):
372+
if not isabs(path):
373+
path = join(os.getcwd(), path)
374+
return normpath(path)

Lib/posixpath.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,10 @@ def normpath(path):
367367
if not comps and not slashes:
368368
comps.append('.')
369369
return slashes + string.joinfields(comps, '/')
370+
371+
372+
# Return an absolute path.
373+
def abspath(path):
374+
if not isabs(path):
375+
path = join(os.getcwd(), path)
376+
return normpath(path)

0 commit comments

Comments
 (0)