diff options
| author | Andrew M. Kuchling <amk@amk.ca> | 2002-11-26 17:42:48 +0000 |
|---|---|---|
| committer | Andrew M. Kuchling <amk@amk.ca> | 2002-11-26 17:42:48 +0000 |
| commit | 7e77495f1012854570db4870dcd839ce9ece7854 (patch) | |
| tree | 425c75713a34f366b674c0ae84e2f58baf63e57e /dir_util.py | |
| parent | fc4c1ada98f887c3423daee9c803753513fba0ba (diff) | |
| download | python-setuptools-git-7e77495f1012854570db4870dcd839ce9ece7854.tar.gz | |
Part of the fix for bug #410541: add ensure_relative() function
Diffstat (limited to 'dir_util.py')
| -rw-r--r-- | dir_util.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/dir_util.py b/dir_util.py index ca9fa9dc..bd1ea0f2 100644 --- a/dir_util.py +++ b/dir_util.py @@ -6,7 +6,7 @@ Utility functions for manipulating directories and directory trees.""" __revision__ = "$Id$" -import os +import os, sys from types import * from distutils.errors import DistutilsFileError, DistutilsInternalError from distutils import log @@ -212,3 +212,17 @@ def remove_tree (directory, verbose=0, dry_run=0): except (IOError, OSError), exc: log.warn(grok_environment_error( exc, "error removing %s: " % directory)) + + +def ensure_relative (path): + """Take the full path 'path', and make it a relative path so + it can be the second argument to os.path.join(). + """ + drive, path = os.path.splitdrive(path) + if sys.platform == 'mac': + return os.sep + path + else: + if path[0:1] == os.sep: + path = drive + path[1:] + return path + |
