MCPcopy Index your code
hub / github.com/microsoft/SandDance / _get_data_files

Function _get_data_files

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

Expand data file specs into valid data files metadata. Parameters ---------- data_specs: list of tuples See [create_cmdclass] for description. existing: list of tuples The existing distrubution data_files metadata. Returns ------- A valid list of data_fi

(data_specs, existing, top=HERE)

Source from the content-addressed store, hash-verified

514
515
516def _get_data_files(data_specs, existing, top=HERE):
517 """Expand data file specs into valid data files metadata.
518
519 Parameters
520 ----------
521 data_specs: list of tuples
522 See [create_cmdclass] for description.
523 existing: list of tuples
524 The existing distrubution data_files metadata.
525
526 Returns
527 -------
528 A valid list of data_files items.
529 """
530 # Extract the existing data files into a staging object.
531 file_data = defaultdict(list)
532 for (path, files) in existing or []:
533 file_data[path] = files
534
535 # Extract the files and assign them to the proper data
536 # files path.
537 for (path, dname, pattern) in data_specs or []:
538 if os.path.isabs(dname):
539 dname = os.path.relpath(dname, top)
540 dname = dname.replace(os.sep, '/')
541 offset = 0 if dname in ('.', '') else len(dname) + 1
542 files = _get_files(_glob_pjoin(dname, pattern), top=top)
543 for fname in files:
544 # Normalize the path.
545 root = os.path.dirname(fname)
546 full_path = _glob_pjoin(path, root[offset:])
547 print(dname, root, full_path, offset)
548 if full_path.endswith('/'):
549 full_path = full_path[:-1]
550 file_data[full_path].append(fname)
551
552 # Construct the data files spec.
553 data_files = []
554 for (path, files) in file_data.items():
555 data_files.append((path, files))
556 return data_files
557
558
559def _get_files(file_patterns, top=HERE):

Callers 1

runMethod · 0.85

Calls 3

_get_filesFunction · 0.85
_glob_pjoinFunction · 0.85
replaceMethod · 0.80

Tested by

no test coverage detected