26 lines
815 B
Python
26 lines
815 B
Python
from polly import parse_patch_file
|
|
from polly import parse_location
|
|
|
|
from pathlib import Path
|
|
|
|
from ..task.util import *
|
|
|
|
def read_insertion(action, patch_file):
|
|
with open(patch_file, 'r') as f:
|
|
src = f.read()
|
|
location = parse_location(action["at"], src)
|
|
|
|
|
|
def process_patch_file(patch_file: str, check_date: bool = True):
|
|
patches = parse_patch_file(patch_file)
|
|
|
|
for patch in patches:
|
|
target_dest = (PATCHED_RSC_DIR / patch["target"])
|
|
if check_date and target_dest.exists() and target_dest.stat().st_mtime > patch["timestamp"]:
|
|
# Patch skipped
|
|
continue
|
|
|
|
insertions = [read_insertion(action) for action in patch["actions"]]
|
|
insertions = [x for x in insertions if x is not None]
|
|
|
|
|