Implement walkdir. fixes #8814#13707
Conversation
|
Years after we first argued about adding a function to do this, I hope we can add this one. |
base/file.jl
Outdated
There was a problem hiding this comment.
traversed top-down or bottom-up?
|
@tkelman I have addressed the comments and force pushed a new version. |
base/file.jl
Outdated
There was a problem hiding this comment.
missed a typo, traversed not transversed
|
This is really nicely done and well tested, so +1 from me. It'll either have to be exported from Base or qualified in the tests. If it gets exported, then a signature for it should be added in the RST stdlib docs so |
504281b to
af2f650
Compare
I have now exported it from Base. How should I add it to RST stdlib docs, any good examples? |
|
The process is described at https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#improving-documentation, sorry it's slightly messy at the moment. Take a look at https://raw.githubusercontent.com/JuliaLang/julia/master/doc/stdlib/file.rst, I think what you have to do is populate just the first |
|
Ok. I have possibly found a good way to test the |
eeba237 to
a9780eb
Compare
|
I have added test for the My Ubuntu cannot build due to an openssl error while building dependencies. I will see if I can figure it out, but it will not be before Sunday. |
|
apt-get install libssl-dev What's the justification for ignoring errors by default? What kind of scenarios would cause errors? I don't like the sound of ignoring errors by default, but how often would errors be expected? |
test/file.jl
Outdated
There was a problem hiding this comment.
can't merge like this, cleanup is necessary on windows too
The default is to throw all errors, if you pass a different function to onerrors it applies that to the error (if it's a SystemError), if it's not a SystemError it raises no matter what. I'm not a huge fan of that API however, I think a Boolean (or even a String) to throw/suppress errors would be better than passing around a function - that's the python API but it seems a little un-julian. |
The
Errors will occur if the user move directories or change the current working directory while using a relative path to the root directory while iterating
The API is made with a function because then the user could make some kind of handling of the missing dir. Python's edit: |
|
Utopic is 14.10, right? I think that went end-of-life a few months ago: http://fridge.ubuntu.com/2015/07/03/ubuntu-14-10-utopic-unicorn-reaches-end-of-life-on-july-23-2015/ so you probably need to The handling callback seems okay to me and more flexible than a boolean flag. Though moving files around during |
|
I have executed |
|
30,000th travis build passed! |
|
This seems useful also for 0.4, is there any chance of a backport? |
|
I'd rather avoid backporting new features in most cases, especially not without being proven on master for some time. This is a pretty small amount of pure julia code and could easily be put in a package, even Compat.jl, for use on 0.4 and even 0.3. |
|
Putting it in Compat is the right way to go. As a policy, we don't backport features. |
This implements a
walkdirfunction equivalent to Python'sos.walk. I have added test for the function and it's keyword arguments. Please correct the docs, as I am not a native speaker. My only remaining question is whetherwalkdirshould do asos.walkand swallow errors as default.Fixes #8814