Message48228
Logged In: YES
user_id=764593
I think the patch is still missing a case or two.
plen represents the length of the path prefix to ignore.
Today's code computes this as (len(src_dir) + 1) where the
+1 is for the "/" added by os.path.join(). As you found,
src_dir won't add anything (including the "/") if src_dir
is empty.
But it also won't add the "/" if src_dir already ends in "/
", and it won't even add the src_dir if the path is already
absolute.
I'm not certain that either of these two cases can occur,
but it would be safer to assume they can.
My suggestion is that the stripping be smarter -- change
"""
# Strip directory from globbed filenames
filenames = [
file[plen:] for file in
self.find_data_files(package, src_dir)
]
"""
to
"""
# Strip directory from globbed filenames
filenames = [
filetail(name, src_dir) for name in
self.find_data_files(package, src_dir)
]
"""
where filetail is a helper function defined as
"""
def filetail(name, strip_path):
if name.startswith(strip_path):
kill=len(strip_path)
if name[kill] == "/":
kill +=1
name=name[kill:]
return name
"""
with tests
"""
>>> filetail("asdf/bdededf", "asdf")
'bdededf'
>>> filetail("asdf/bdededf", "asdf/")
'bdededf'
"""
|
|
Date |
User |
Action |
Args |
2007-08-23 15:42:44 | admin | link | issue1183712 messages |
2007-08-23 15:42:44 | admin | create | |
|