Commit 8496cfb2 authored by Jason R. Coombs's avatar Jason R. Coombs

Use relpath to produce results relative to 'dir'

parent c05680c5
...@@ -143,18 +143,13 @@ def findall(dir=os.curdir): ...@@ -143,18 +143,13 @@ def findall(dir=os.curdir):
"""Find all files under 'dir' and return the list of full filenames """Find all files under 'dir' and return the list of full filenames
(relative to 'dir'). (relative to 'dir').
""" """
def _strip_leading_curdir(base): def _prepend(base):
do_strip = base == os.curdir or base.startswith(os.curdir + os.sep) return functools.partial(os.path.join, os.path.relpath(base, dir))
return base[2:] if do_strip else base
def _base_prepend(base):
base = _strip_leading_curdir(base)
return functools.partial(os.path.join, base)
return [ return [
file file
for base, dirs, files in os.walk(dir, followlinks=True) for base, dirs, files in os.walk(dir, followlinks=True)
for file in map(_base_prepend(base), files) for file in map(_prepend(base), files)
if os.path.isfile(file) if os.path.isfile(file)
] ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment