mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-08 10:34:06 +00:00
Remove old manifests and put everything in folders (#2026)
This commit is contained in:
@@ -45,12 +45,36 @@ def update_monthly_wiki_page(
|
||||
monthly_page.write_text(monthly_page_content)
|
||||
|
||||
|
||||
def get_manifest_timestamp(manifest_file: Path) -> str:
|
||||
file_content = manifest_file.read_text()
|
||||
pos = file_content.find("Build datetime: ")
|
||||
return file_content[pos + 16 : pos + 36]
|
||||
|
||||
|
||||
def get_manifest_month(manifest_file: Path) -> str:
|
||||
return get_manifest_timestamp(manifest_file)[:10]
|
||||
|
||||
|
||||
def remove_old_manifests(wiki_dir: Path) -> None:
|
||||
MAX_NUMBER_OF_MANIFESTS = 4500
|
||||
|
||||
manifest_files = []
|
||||
for file in (wiki_dir / "manifests").rglob("*.md"):
|
||||
manifest_files.append((get_manifest_timestamp(file), file))
|
||||
|
||||
manifest_files.sort(reverse=True)
|
||||
for _, file in manifest_files[MAX_NUMBER_OF_MANIFESTS:]:
|
||||
LOGGER.info(f"Removing manifest: {file.name}")
|
||||
file.unlink()
|
||||
|
||||
|
||||
def update_wiki(wiki_dir: Path, hist_line_dir: Path, manifest_dir: Path) -> None:
|
||||
LOGGER.info("Updating wiki")
|
||||
|
||||
LOGGER.info("Copying manifest files")
|
||||
for manifest_file in manifest_dir.glob("*.md"):
|
||||
shutil.copy(manifest_file, wiki_dir / "manifests" / manifest_file.name)
|
||||
month = get_manifest_month(manifest_file)
|
||||
shutil.copy(manifest_file, wiki_dir / "manifests" / month / manifest_file.name)
|
||||
LOGGER.info(f"Manifest file added: {manifest_file.name}")
|
||||
|
||||
for build_history_line_file in sorted(hist_line_dir.glob("*.txt")):
|
||||
@@ -60,6 +84,8 @@ def update_wiki(wiki_dir: Path, hist_line_dir: Path, manifest_dir: Path) -> None
|
||||
update_home_wiki_page(wiki_dir, month)
|
||||
update_monthly_wiki_page(wiki_dir, month, build_history_line)
|
||||
|
||||
remove_old_manifests(wiki_dir)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
Reference in New Issue
Block a user