File: download_htmx_extensions.py

package info (click to toggle)
django-htmx 1.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 816 kB
  • sloc: javascript: 3,395; python: 956; makefile: 27; sh: 19
file content (42 lines) | stat: -rwxr-xr-x 891 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python
"""
Download the htmx version and the extensions we're using.

This is only intended for maintaining the example app.
"""

from __future__ import annotations

import subprocess
from pathlib import Path

ext_dir = Path(__file__).parent.resolve() / "example/static/ext"


def main() -> int:
    # Per: https://github.com/bigskysoftware/htmx-extensions/tree/main/src/event-header
    download_file(
        "https://unpkg.com/htmx-ext-event-header/event-header.js",
        ext_dir / "event-header.js",
    )

    print("✅")
    return 0


def download_file(url: str, destination: Path) -> None:
    print(f"{destination.name}...")
    subprocess.run(
        [
            "curl",
            "--fail",
            "--location",
            url,
            "-o",
            str(destination),
        ],
    )


if __name__ == "__main__":
    raise SystemExit(main())