/[thuban]/branches/WIP-pyshapelib-bramz/Thuban/Lib/fileutil.py
ViewVC logotype

Diff of /branches/WIP-pyshapelib-bramz/Thuban/Lib/fileutil.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 6 by bh, Tue Aug 28 15:41:52 2001 UTC revision 374 by jan, Mon Jan 27 14:20:02 2003 UTC
# Line 1  Line 1 
1  # Copyright (c) 2001 by Intevation GmbH  # Copyright (c) 2001, 2002 by Intevation GmbH
2  # Authors:  # Authors:
3  # Bernhard Herzog <[email protected]>  # Bernhard Herzog <[email protected]>
4  #  #
# Line 14  __version__ = "$Revision$" Line 14  __version__ = "$Revision$"
14  import os.path  import os.path
15  from string import split, join  from string import split, join
16    
17    from Thuban import _
18    
19  def relative_filename_common(dir, absname, sep):  def relative_filename_common(dir, absname, sep):
20      """Return a filename relative to dir for the absolute file name absname.      """Return a filename relative to dir for the absolute file name absname.
# Line 77  def relative_filename_posix(dir, absname Line 78  def relative_filename_posix(dir, absname
78      # for that to faciliate testing      # for that to faciliate testing
79      import posixpath      import posixpath
80      if not posixpath.isabs(absname):      if not posixpath.isabs(absname):
81          return absname          return absname
82    
83      if not posixpath.isabs(dir):      if not posixpath.isabs(dir):
84          raise TypeError("first argument must be an absolute filename")          raise TypeError(_("first argument must be an absolute filename"))
85    
86      dir = posixpath.normpath(dir)      dir = posixpath.normpath(dir)
87      absname = posixpath.normpath(absname)      absname = posixpath.normpath(absname)
# Line 131  def relative_filename_nt(dir, absname): Line 132  def relative_filename_nt(dir, absname):
132      #print dir_drive, dir_rest      #print dir_drive, dir_rest
133      #print absname_drive, absname_rest      #print absname_drive, absname_rest
134      if not dir_drive or not absname_drive:      if not dir_drive or not absname_drive:
135          raise TypeError("Both parameters must have a drive letter")          raise TypeError(_("Both parameters must have a drive letter"))
136    
137      if not ntpath.isabs(dir_rest):      if not ntpath.isabs(dir_rest):
138          raise TypeError("first argument must be an absolute filename")          raise TypeError(_("first argument must be an absolute filename"))
139    
140      # handle some special cases      # handle some special cases
141      if not ntpath.isabs(absname_rest):      if not ntpath.isabs(absname_rest):
142          return absname          return absname
143    
144      if dir_drive != absname_drive:      if dir_drive != absname_drive:
145          return absname          return absname
# Line 149  def relative_filename_nt(dir, absname): Line 150  def relative_filename_nt(dir, absname):
150      return relative_filename_common(dir_rest, absname_rest, "\\")      return relative_filename_common(dir_rest, absname_rest, "\\")
151    
152    
153  # bind the appriate version of relative_filename for the platform we're  # bind the appropriate version of relative_filename for the platform
154  # currently running on.  # we're currently running on.
155  if os.name == "posix":  if os.name == "posix":
156      relative_filename = relative_filename_posix      relative_filename = relative_filename_posix
157  elif os.name == "nt":  elif os.name == "nt":
158      relative_filename = relative_filename_nt      relative_filename = relative_filename_nt
159  else:  else:
160      raise RuntimeError("No implementation of relative_filename"      raise RuntimeError(_("No implementation of relative_filename"
161                         " available for platform" + os.name)                         " available for platform") + os.name)
162    
163  __test__ = {"relative_filename_posix": relative_filename_posix,  __test__ = {"relative_filename_posix": relative_filename_posix,
164              "relative_filename_nt": relative_filename_nt}              "relative_filename_nt": relative_filename_nt}

Legend:
Removed from v.6  
changed lines
  Added in v.374

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26