File size: 1,076 Bytes
fa0cf56
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b19472
8878a5a
fa0cf56
 
 
 
 
 
 
 
 
 
 
 
8878a5a
fa0cf56
 
 
4b19472
fa0cf56
 
 
 
4b19472
fa0cf56
 
 
 
 
 
 
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
43
44
45
46
47
48
#!/usr/bin/env python3

from typing import List
from pathlib import Path

BASE_URL = "https://huggingface.co/csukuangfj/k2/resolve/main/"


def generate_url(files: List[str]) -> List[str]:
    ans = []
    base = BASE_URL
    for f in files:
        ans.append(base + str(f))
    return ans


def get_all_files(d: str, suffix: str) -> List[str]:
    return sorted(Path(d).glob(suffix), reverse=True)


def to_markdown(urls: List[str]) -> List[str]:
    ans = []
    for url in urls:
        name = url.rsplit("/", maxsplit=1)[1]
        ans.append(f"[{name}]({url})")
    return ans


def to_file(filename: str, md: List[str]):
    with open(filename, "w") as f:
        f.write("<br/>\n".join(md))


def main():
    cpu = get_all_files("cpu", suffix="*.whl")
    cpu_wheels = generate_url(cpu)
    cpu_wheels = to_markdown(cpu_wheels)
    to_file("cpu.md", cpu_wheels)

    cuda = get_all_files("cuda", suffix="*.whl")
    cuda_wheels = generate_url(cuda)
    cuda_wheels = to_markdown(cuda_wheels)
    to_file("cuda.md", cuda_wheels)


if __name__ == "__main__":
    main()