Recursive version of GLOB. Builds the glob of files while also searching in the subdirectories of the given roots. An optional set of exclusion patterns will filter out the matching entries from the result. The exclusions also apply to the subdirectory scanning, such that directories
(roots, patterns, exclude_patterns=None)
| 837 | return [x for x in inc if x not in exc] |
| 838 | |
| 839 | def glob_tree(roots, patterns, exclude_patterns=None): |
| 840 | """Recursive version of GLOB. Builds the glob of files while |
| 841 | also searching in the subdirectories of the given roots. An |
| 842 | optional set of exclusion patterns will filter out the |
| 843 | matching entries from the result. The exclusions also apply |
| 844 | to the subdirectory scanning, such that directories that |
| 845 | match the exclusion patterns will not be searched.""" |
| 846 | |
| 847 | if not exclude_patterns: |
| 848 | exclude_patterns = [] |
| 849 | |
| 850 | result = glob(roots, patterns, exclude_patterns) |
| 851 | subdirs = [s for s in glob(roots, ["*"]) if s != "." and s != ".." and os.path.isdir(s)] |
| 852 | if subdirs: |
| 853 | result.extend(glob_tree(subdirs, patterns, exclude_patterns)) |
| 854 | |
| 855 | return result |
| 856 | |
| 857 | def glob_in_parents(dir, patterns, upper_limit=None): |
| 858 | """Recursive version of GLOB which glob sall parent directories |