#13928: Problematic file filter in skip() from sage-ptest
---------------------------------+------------------------------------------
Reporter: ncohen | Owner: mvngu
Type: defect | Status: needs_review
Priority: major | Milestone: sage-5.6
Component: doctest | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Nathann Cohen | Merged in:
Dependencies: | Stopgaps:
---------------------------------+------------------------------------------
Comment (by nbruin):
Ah, got it. `populatefilelist` uses `os.walk` to recurse into the
directory tree and that has no problem following into hidden files. Hence
the solution to prune these afterwards. That's the wrong approach of
course: You shouldn't follow/include these things in the first place. So
`os.walk` is the wrong tool. Nathan, you got your job cut out for you:
rewrite `populatefilelist` to include files into the list a little more
prudently, so that `skip` doesn't have to do so much pruning.
Actually, `os.walk` ''is'' the proper tool, but you have to run it with
`topdown=True` (which is the default anyway). See
[http://docs.python.org/2/library/os.html#os.walk os.walk documentation].
Then you can edit `dirnames` in-place, to affect further recursions. So,
if you write something like this in `populatefilelist`:
{{{
for path,dirnames,lfiles in os.walk(walkdir):
for i in range(len(dirnames)-1,-1,-1):
if len(dirnames[i]) > 0 and dirnames[i][0] == '.':
del dirnames[i]
for i in range(len(lfiles)-1,-1,-1):
if len(lfiles[i]) > 0 and lfiles[i][0] == '.':
del lfiles[i]
<do your processing here>
}}}
there shouldn't be a need for `skip` to explicitly filter out dotted
filenames anymore.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13928#comment:19>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.