MCPcopy Index your code
hub / github.com/RustPython/RustPython / patch_single_content

Function patch_single_content

scripts/update_lib/cmd_migrate.py:24–48  ·  view source on GitHub ↗

Patch content without writing to disk. Args: src_path: Source file path (e.g., cpython/Lib/test/foo.py) lib_path: Lib path to extract patches from (e.g., Lib/test/foo.py) Returns: The patched content.

(
    src_path: pathlib.Path,
    lib_path: pathlib.Path,
)

Source from the content-addressed store, hash-verified

22
23
24def patch_single_content(
25 src_path: pathlib.Path,
26 lib_path: pathlib.Path,
27) -> str:
28 """
29 Patch content without writing to disk.
30
31 Args:
32 src_path: Source file path (e.g., cpython/Lib/test/foo.py)
33 lib_path: Lib path to extract patches from (e.g., Lib/test/foo.py)
34
35 Returns:
36 The patched content.
37 """
38 from update_lib import apply_patches, extract_patches
39
40 # Extract patches from existing file (if exists)
41 if lib_path.exists():
42 patches = extract_patches(lib_path.read_text(encoding="utf-8"))
43 else:
44 patches = {}
45
46 # Apply patches to source content
47 src_content = src_path.read_text(encoding="utf-8")
48 return apply_patches(src_content, patches)
49
50
51def patch_file(

Callers 4

patch_fileFunction · 0.85
patch_directoryFunction · 0.85

Calls 4

extract_patchesFunction · 0.90
apply_patchesFunction · 0.90
existsMethod · 0.45
read_textMethod · 0.45