|
|
|
|
|
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() |
|
|