findtools (GitHub) is a file-globbing library, inspired by GNU Findutils. An example, from README:
from findtools.find_files import (find_files, Match) # Recursively find all *.sh files in **/usr/bin** sh_files_pattern = Match(filetype='f', name='*.sh') found_files = find_files(path='/usr/bin', match=sh_files_pattern) for found_file in found_files: print found_file
It will produce a result like:
/usr/bin/lesspipe.sh /usr/bin/gettext.sh [snip]
You can set up file type, like regular file, directory, etc. Just like you do with find using -type. The pattern is down using fnmatch module for Unix filename pattern matching, which translate to regular expression internally, you can use pattern like foo*-[1-3]-r?.tar.gz.
Although its inspiration can be seen in the file type, frankly, there is still a big gap between two. findtools has a lot of things can be improved. For example, supporting regular expression, date matching, output format, etc.
findtools is written by Yauhen Yakimovich under the GPLv3, currently version 1.0.0 (2014-04-10).
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.