A `PreImage` action which copies files from a directory. See doc/developer/mzbuild.md for an explanation of the user-facing parameters.
| 552 | |
| 553 | |
| 554 | class Copy(PreImage): |
| 555 | """A `PreImage` action which copies files from a directory. |
| 556 | |
| 557 | See doc/developer/mzbuild.md for an explanation of the user-facing |
| 558 | parameters. |
| 559 | """ |
| 560 | |
| 561 | def __init__(self, rd: RepositoryDetails, path: Path, config: dict[str, Any]): |
| 562 | super().__init__(rd, path) |
| 563 | |
| 564 | self.source = config.pop("source", None) |
| 565 | if self.source is None: |
| 566 | raise ValueError("mzbuild config is missing 'source' argument") |
| 567 | |
| 568 | self.destination = config.pop("destination", None) |
| 569 | if self.destination is None: |
| 570 | raise ValueError("mzbuild config is missing 'destination' argument") |
| 571 | |
| 572 | self.matching = config.pop("matching", "*") |
| 573 | |
| 574 | def run(self, prep: Any) -> None: |
| 575 | super().run(prep) |
| 576 | for src in self.inputs(): |
| 577 | dst = self.path / self.destination / src |
| 578 | dst.parent.mkdir(parents=True, exist_ok=True) |
| 579 | shutil.copy(self.rd.root / self.source / src, dst) |
| 580 | |
| 581 | def inputs(self) -> set[str]: |
| 582 | return set(git.expand_globs(self.rd.root / self.source, self.matching)) |
| 583 | |
| 584 | |
| 585 | class CargoPreImage(PreImage): |