MCPcopy
hub / github.com/microsoft/SandDance / _get_files

Function _get_files

python/jupyter-widget/setupbase.py:559–597  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

557
558
559def _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
600def _get_package_data(root, file_patterns=None):

Callers 2

_get_data_filesFunction · 0.85
_get_package_dataFunction · 0.85

Calls 7

_compile_patternFunction · 0.85
_glob_pjoinFunction · 0.85
listFunction · 0.85
replaceMethod · 0.80
setFunction · 0.50
removeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected