MCPcopy Index your code
hub / github.com/python/cpython / copy_files

Function copy_files

PC/layout/main.py:448–538  ·  view source on GitHub ↗
(files, ns)

Source from the content-addressed store, hash-verified

446
447
448def copy_files(files, ns):
449 if ns.copy:
450 ns.copy.mkdir(parents=True, exist_ok=True)
451
452 try:
453 total = len(files)
454 except TypeError:
455 total = None
456 count = 0
457
458 zip_file = _create_zip_file(ns)
459 try:
460 need_compile = []
461 in_catalog = []
462
463 for dest, src in files:
464 count += 1
465 if count % 10 == 0:
466 if total:
467 log_info("Processed {:>4} of {} files", count, total)
468 else:
469 log_info("Processed {} files", count)
470 log_debug("Processing {!s}", src)
471
472 if isinstance(src, tuple):
473 src, content = src
474 if ns.copy:
475 log_debug("Copy {} -> {}", src, ns.copy / dest)
476 (ns.copy / dest).parent.mkdir(parents=True, exist_ok=True)
477 with open(ns.copy / dest, "wb") as f:
478 f.write(content)
479 if ns.zip:
480 log_debug("Zip {} into {}", src, ns.zip)
481 zip_file.writestr(str(dest), content)
482 continue
483
484 if (
485 ns.precompile
486 and src in PY_FILES
487 and src not in EXCLUDE_FROM_COMPILE
488 and src.parent not in DATA_DIRS
489 and os.path.normcase(str(dest)).startswith(os.path.normcase("Lib"))
490 ):
491 if ns.copy:
492 need_compile.append((dest, ns.copy / dest))
493 else:
494 (ns.temp / "Lib" / dest).parent.mkdir(parents=True, exist_ok=True)
495 copy_if_modified(src, ns.temp / "Lib" / dest)
496 need_compile.append((dest, ns.temp / "Lib" / dest))
497
498 if src not in EXCLUDE_FROM_CATALOG:
499 in_catalog.append((src.name, src))
500
501 if ns.copy:
502 log_debug("Copy {} -> {}", src, ns.copy / dest)
503 (ns.copy / dest).parent.mkdir(parents=True, exist_ok=True)
504 try:
505 copy_if_modified(src, ns.copy / dest)

Callers 1

mainFunction · 0.85

Calls 15

PathClass · 0.90
_create_zip_fileFunction · 0.85
log_infoFunction · 0.85
log_debugFunction · 0.85
strFunction · 0.85
copy_if_modifiedFunction · 0.85
_compile_one_pyFunction · 0.85
write_catalogFunction · 0.85
writestrMethod · 0.80
normcaseMethod · 0.80
openFunction · 0.50
mkdirMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…