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. |
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) |
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): |
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} |