2021-03-28 13:49:19 +03:00
|
|
|
#!/bin/env python3
|
|
|
|
import sys
|
|
|
|
|
|
|
|
import fileinput
|
|
|
|
import re
|
|
|
|
|
|
|
|
Meta = { }
|
|
|
|
for line in sys.stdin.readlines():
|
|
|
|
if detailed := re.findall("^([A-Za-z0-9]+)/([A-Za-z0-9]+):(.+)$", line):
|
|
|
|
detailed = detailed[0]
|
|
|
|
meta = detailed[0].strip() + "/" + detailed[1].strip()
|
|
|
|
if meta not in Meta:
|
|
|
|
Meta[meta] = []
|
|
|
|
Meta[meta].append(detailed[2].strip())
|
|
|
|
elif category := re.findall("(^[A-Za-z0-9]+):(.+)$", line):
|
|
|
|
category = category[0]
|
|
|
|
if category[0].strip() not in Meta:
|
|
|
|
Meta[category[0].strip()] = []
|
|
|
|
Meta[category[0].strip()].append(category[1].strip())
|
|
|
|
else:
|
|
|
|
if "_Misc" not in Meta:
|
|
|
|
Meta["_Misc"] = []
|
|
|
|
Meta["_Misc"].append(line.strip())
|
|
|
|
|
2021-03-30 11:19:01 +03:00
|
|
|
print(sys.argv[1])
|
2021-03-28 13:49:19 +03:00
|
|
|
|
|
|
|
Category = ""
|
|
|
|
Tag = ""
|
|
|
|
for item in sorted(Meta.items()):
|
|
|
|
if item[0] == "_Misc":
|
|
|
|
tag = "Misc"
|
|
|
|
else:
|
|
|
|
tag = item[0]
|
|
|
|
|
|
|
|
category = tag.split("/")[0]
|
|
|
|
if category != Category:
|
|
|
|
Category = category
|
|
|
|
Tag = ""
|
|
|
|
print("")
|
2021-03-30 11:19:01 +03:00
|
|
|
print("- " + category)
|
2021-03-28 13:49:19 +03:00
|
|
|
if Tag != tag and tag != category:
|
|
|
|
Tag = tag
|
|
|
|
print("")
|
2021-03-30 11:19:01 +03:00
|
|
|
print(" - " + tag.split("/")[1])
|
2021-03-28 13:49:19 +03:00
|
|
|
|
|
|
|
for change in item[1]:
|
2021-03-30 11:19:01 +03:00
|
|
|
if Tag == "":
|
|
|
|
print(" - " + change)
|
|
|
|
else:
|
|
|
|
print(" - " + change)
|