From fcaf79a0b6bcd20862bc3e6557c0e85a69cd3535 Mon Sep 17 00:00:00 2001 From: CarlGao4 Date: Sat, 17 Aug 2024 10:25:46 +0800 Subject: [PATCH] Fix toc script --- gh-actions-generate-toc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gh-actions-generate-toc.py b/gh-actions-generate-toc.py index bc73129..af86bd2 100644 --- a/gh-actions-generate-toc.py +++ b/gh-actions-generate-toc.py @@ -84,6 +84,8 @@ name = name.split(".", 1)[0] if catagory not in instruments: instruments[catagory] = {} + if catagory not in download_size: + download_size[catagory] = {} if name not in instruments[catagory]: instruments[catagory][name] = {} if name not in download_size[catagory]: @@ -142,8 +144,8 @@ def human_readable_size(size): with open("instruments.md", mode="wt", encoding="utf-8") as f: f.write(markdown) # Find out what instrument changed to set commit message - old_markdown_insts = dict((i[1], i[0]) for i in re.findall(r"(- \[(.*)\].*\r?\n( - .*\r?\n?)*)", old_markdown)) - new_markdown_insts = dict((i[1], i[0]) for i in re.findall(r"(- \[(.*)\].*\r?\n( - .*\r?\n?)*)", markdown)) + old_markdown_insts = dict((i[1], i[0]) for i in re.findall(r"(- \[?(.*)\]?.*\r?\n( - .*\r?\n?)*)", old_markdown)) + new_markdown_insts = dict((i[1], i[0]) for i in re.findall(r"(- \[?(.*)\]?.*\r?\n( - .*\r?\n?)*)", markdown)) added = set(new_markdown_insts.keys()) - set(old_markdown_insts.keys()) removed = set(old_markdown_insts.keys()) - set(new_markdown_insts.keys()) modified = {}