[Python-checkins] CVS: distutils/distutils util.py,1.32,1.33

Greg Ward python-dev@python.org
Tue, 30 May 2000 19:14:34 -0700


Update of /cvsroot/python/distutils/distutils
In directory slayer.i.sourceforge.net:/tmp/cvs-serv21140

Modified Files:
	util.py 
Log Message:
Fixed 'change_root() to work at all on Windows, and to work correctly on Unix.

Index: util.py
===================================================================
RCS file: /cvsroot/python/distutils/distutils/util.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -C2 -r1.32 -r1.33
*** util.py	2000/05/12 00:40:00	1.32
--- util.py	2000/05/31 02:14:32	1.33
***************
*** 6,10 ****
  # created 1999/03/08, Greg Ward
  
! __revision__ = "$Id: util.py,v 1.32 2000/05/12 00:40:00 greg Exp $"
  
  import sys, os, string, re, shutil
--- 6,10 ----
  # created 1999/03/08, Greg Ward
  
! __revision__ = "$Id: util.py,v 1.33 2000/05/31 02:14:32 gward Exp $"
  
  import sys, os, string, re, shutil
***************
*** 87,106 ****
  
  def change_root (new_root, pathname):
- 
      """Return 'pathname' with 'new_root' prepended.  If 'pathname' is
      relative, this is equivalent to "os.path.join(new_root,pathname)".
      Otherwise, it requires making 'pathname' relative and then joining the
!     two, which is tricky on DOS/Windows and Mac OS."""
! 
!     if not abspath (pathname):
!         return os.path.join (new_root, pathname)
! 
!     elif os.name == 'posix':
!         return os.path.join (new_root, pathname[1:])
  
      elif os.name == 'nt':
-         (root_drive, root_path) = os.path.splitdrive (new_root)
          (drive, path) = os.path.splitdrive (pathname)
!         raise RuntimeError, "I give up -- not sure how to do this on Windows"
  
      elif os.name == 'mac':
--- 87,106 ----
  
  def change_root (new_root, pathname):
      """Return 'pathname' with 'new_root' prepended.  If 'pathname' is
      relative, this is equivalent to "os.path.join(new_root,pathname)".
      Otherwise, it requires making 'pathname' relative and then joining the
!     two, which is tricky on DOS/Windows and Mac OS.
!     """
!     if os.name == 'posix':
!         if not os.path.isabs (pathname):
!             return os.path.join (new_root, pathname)
!         else:
!             return os.path.join (new_root, pathname[1:])
  
      elif os.name == 'nt':
          (drive, path) = os.path.splitdrive (pathname)
!         if path[0] == '\\':
!             path = path[1:]
!         return os.path.join (new_root, path)
  
      elif os.name == 'mac':