Update patterns for spoilering

This commit is contained in:
Alwinfy 2023-02-18 21:05:52 -05:00
parent a6b438dd76
commit 182b8fc617
No known key found for this signature in database
GPG key ID: 2CCB99445F0C949E
2 changed files with 4 additions and 2 deletions

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from sys import argv, stdout from sys import argv, stdout
from collections import namedtuple from collections import namedtuple
from fnmatch import fnmatch
from html import escape from html import escape
import json # codec import json # codec
import re # parsing import re # parsing
@ -397,7 +398,8 @@ def get_format(out, ty, value):
raise ValueError("Unknown format type: " + ty) raise ValueError("Unknown format type: " + ty)
def entry_spoilered(root_info, entry): def entry_spoilered(root_info, entry):
return entry.get("advancement", None) in root_info["spoilers"] if "advancement" not in entry: return False
return any(fnmatch(entry["advancement"], pat) for pat in root_info["spoilers"])
def category_spoilered(root_info, category): def category_spoilered(root_info, category):
return all(entry_spoilered(root_info, ent) for ent in category["entries"]) return all(entry_spoilered(root_info, ent) for ent in category["entries"])

View file

@ -394,7 +394,7 @@
</p> </p>
</blockquote> </blockquote>
</div> </div>
#SPOILER hexcasting:opened_eyes hexcasting:y_u_no_cast_angy hexcasting:enlightenment #SPOILER hexcasting:opened_eyes hexcasting:y_u_no_cast_angy hexcasting:enlightenment hexcasting:lore/*
#DUMP_BODY_HERE #DUMP_BODY_HERE
</body> </body>
</html> </html>