Expand file patterns to a list of paths. Parameters ----------- file_patterns: list or str A list of glob patterns for the data file locations. The globs can be recursive if they include a `**`. They should be relative paths from the top directory or abso
(file_patterns, top=HERE)
| 557 | |
| 558 | |
| 559 | def _get_files(file_patterns, top=HERE): |
| 560 | """Expand file patterns to a list of paths. |
| 561 | |
| 562 | Parameters |
| 563 | ----------- |
| 564 | file_patterns: list or str |
| 565 | A list of glob patterns for the data file locations. |
| 566 | The globs can be recursive if they include a `**`. |
| 567 | They should be relative paths from the top directory or |
| 568 | absolute paths. |
| 569 | top: str |
| 570 | the directory to consider for data files |
| 571 | |
| 572 | Note: |
| 573 | Files in `node_modules` are ignored. |
| 574 | """ |
| 575 | if not isinstance(file_patterns, (list, tuple)): |
| 576 | file_patterns = [file_patterns] |
| 577 | |
| 578 | for i, p in enumerate(file_patterns): |
| 579 | if os.path.isabs(p): |
| 580 | file_patterns[i] = os.path.relpath(p, top) |
| 581 | |
| 582 | matchers = [_compile_pattern(p) for p in file_patterns] |
| 583 | |
| 584 | files = set() |
| 585 | |
| 586 | for root, dirnames, filenames in os.walk(top): |
| 587 | # Don't recurse into node_modules |
| 588 | if 'node_modules' in dirnames: |
| 589 | dirnames.remove('node_modules') |
| 590 | for m in matchers: |
| 591 | for filename in filenames: |
| 592 | fn = os.path.relpath(_glob_pjoin(root, filename), top) |
| 593 | fn = fn.replace(os.sep, '/') |
| 594 | if m(fn): |
| 595 | files.add(fn.replace(os.sep, '/')) |
| 596 | |
| 597 | return list(files) |
| 598 | |
| 599 | |
| 600 | def _get_package_data(root, file_patterns=None): |
no test coverage detected