Searches a list of filenames and replaces directories in the list with all files descending from those directories. Files with extensions not in the valid extensions list are excluded. Args: filenames: A list of files or directories Returns: A list of all files that are members of
(filenames)
| 6818 | return filenames |
| 6819 | |
| 6820 | def _ExpandDirectories(filenames): |
| 6821 | """Searches a list of filenames and replaces directories in the list with |
| 6822 | all files descending from those directories. Files with extensions not in |
| 6823 | the valid extensions list are excluded. |
| 6824 | |
| 6825 | Args: |
| 6826 | filenames: A list of files or directories |
| 6827 | |
| 6828 | Returns: |
| 6829 | A list of all files that are members of filenames or descended from a |
| 6830 | directory in filenames |
| 6831 | """ |
| 6832 | expanded = set() |
| 6833 | for filename in filenames: |
| 6834 | if not os.path.isdir(filename): |
| 6835 | expanded.add(filename) |
| 6836 | continue |
| 6837 | |
| 6838 | for root, _, files in os.walk(filename): |
| 6839 | for loopfile in files: |
| 6840 | fullname = os.path.join(root, loopfile) |
| 6841 | if fullname.startswith('.' + os.path.sep): |
| 6842 | fullname = fullname[len('.' + os.path.sep):] |
| 6843 | expanded.add(fullname) |
| 6844 | |
| 6845 | filtered = [] |
| 6846 | for filename in expanded: |
| 6847 | if os.path.splitext(filename)[1][1:] in GetAllExtensions(): |
| 6848 | filtered.append(filename) |
| 6849 | return filtered |
| 6850 | |
| 6851 | def _FilterExcludedFiles(fnames): |
| 6852 | """Filters out files listed in the --exclude command line switch. File paths |
no test coverage detected