Closed dbrgn closed 10 years ago
I also added a test for the common environment. It currently fails. We still need to decide how to handle valid/invalid files. Is everything except a directory a valid file? Or is only a file (type f) a valid file? Or maybe files and symlinks?
Btw, this PR raises landscape rating from 83% to 89% :)
Nice work @dbrgn, thx! This whole thing is becoming an engineering masterpiece!
Before merging, we still need to decide whether we count symlinks as files.
RIght now the algorithm for is_file is as follows:
1. If the path doesn't start with `/`, return False
2. If path cannot be opened with os.stat, return False
3. If path is a directory, return False
4. Otherwise, return True
If that's fine, I'll adjust the docstrings and tests accordingly. I'm not sure whether we should allow "is_file" to return on symlinks, named pipes or other strange file-like objects.
Possible object types, according to man find
:
My suggestion would be to include regular files and symlinks.
RFC, @d22 @cfaessler
Reorganized imports
Moved common code from environment subclasses to CommonEnvironment
get_os_string
is already in CommonEnvironment and does not need to be redefined.is_file
method to CommonEnvironment.staticmethod
toclassmethod
.Encoding Fixes
Other Fixes
Please review, @cfaessler