#!/usr/bin/env python3
import os
import hashlib
import re
pip_index = open("index.html", "w")
pip_index.write("""
yt-dlp-rajiko pip index
""")
site_sha256 = []
tarballs = []
wheels = []
for item in sorted(os.listdir()):#, key=lambda x: x.name):
if os.path.islink(item):
continue
if item.endswith(".tar.gz"):
tarballs.append(item)
elif item.endswith(".whl"):
wheels.append(item)
else:
continue
pip_index.write("\t- ")
pip_index.write('')
pip_index.write(item)
pip_index.write("\n")
site_string = checksum + " " + '' + item + "
"
site_sha256.append(site_string)
pip_index.write("""
""")
latest_tarball = tarballs[-1]
latest_wheel = wheels[-1]
print(latest_tarball, latest_wheel)
os.remove("yt_dlp_rajiko-latest.tar.gz")
os.symlink(latest_tarball, "yt_dlp_rajiko-latest.tar.gz")
os.remove("yt_dlp_rajiko-latest.whl")
os.symlink(latest_wheel, "yt_dlp_rajiko-latest.whl")
site_sha256.reverse()
latest_list = site_sha256[:2]
previous_list = site_sha256[2:]
latest = "\n".join(["", "", "\n".join(latest_list), "
", ""])
previous = "\n".join(["", "", "\n".join(previous_list), "
", ""])
for i in ["../../index.html", "../../index.ja.html"]:
with open(i, "r+") as f:
page = f.read()
page = re.sub(r".+", latest, page, flags=re.DOTALL)
page = re.sub(r".+", previous, page, flags=re.DOTALL)
f.seek(0)
f.truncate(0)
f.write(page)