Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ repos:
entry: check-jsonschema
pass_filenames: true
language: python
additional_dependencies: ["check-jsonschema==0.37.0"]
additional_dependencies: ["check-jsonschema==0.37.1"]
# This calls a remote URL, so run on pre-push to avoid slowing down commits
stages: ["pre-push"]
id: check-pyproject-schema
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ After copying, find and replace on:

Install [uv](https://docs.astral.sh/uv/getting-started/installation/) and then install the dependencies:

```bash
```shell
uvx --from poethepoet poe install
```
53 changes: 53 additions & 0 deletions tools/apply.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import argparse
import logging
import pathlib
import shutil
from collections.abc import Sequence

SUCCESS = 0
FAILURE = 1
ROOT = pathlib.Path(__file__).parent.parent
FILES_TO_COPY = [
".github/workflows/tests.yaml",
".gitignore",
".pre-commit-config.yaml",
"LICENSE",
"pyproject.toml",
]


def copy_files_to_target(target: pathlib.Path) -> int:
if not target.exists():
logging.error(f"target {target} does not exist")
return FAILURE
if not target.is_dir():
logging.error(f"target {target} is not a directory")
return FAILURE

for file in FILES_TO_COPY:
shutil.copy(ROOT / file, target / file)

return SUCCESS


def main(argv: Sequence[str] | None = None) -> int:
"""
Parse the arguments and run the command.
"""

parser = argparse.ArgumentParser()
parser.add_argument("targets", nargs="*")

args = parser.parse_args(argv)
ret = SUCCESS
if not args.targets:
parser.print_help()
for target in args.targets:
ret |= copy_files_to_target(target=pathlib.Path(target))

return ret


if __name__ == "__main__":
# python -m tools.apply <target>
raise SystemExit(main())