mirror of
https://github.com/Cockatrice/Magic-Spoiler.git
synced 2026-04-23 07:28:39 -05:00
Merge pull request #272 from ebbit1q/fixes
quick improvements to spoilers
This commit is contained in:
commit
4ea02869be
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -86,6 +86,7 @@ celerybeat-schedule
|
|||
venv/
|
||||
ENV/
|
||||
bin/
|
||||
include/
|
||||
pyvenv.cfg
|
||||
|
||||
# Spyder project settings
|
||||
|
|
|
|||
|
|
@ -17,11 +17,14 @@ from lxml import etree
|
|||
SCRYFALL_SET_URL: str = "https://api.scryfall.com/sets/{}"
|
||||
SESSION: contextvars.ContextVar = contextvars.ContextVar("SESSION_SCRYFALL")
|
||||
SPOILER_SETS: contextvars.ContextVar = contextvars.ContextVar("SPOILER_SETS")
|
||||
SPOILER_MARK = "*"
|
||||
|
||||
OUTPUT_DIR = pathlib.Path("out")
|
||||
OUTPUT_TMP_DIR = OUTPUT_DIR.joinpath("tmp")
|
||||
XML_ESCAPE_TRANSLATE_MAP = str.maketrans(
|
||||
{"&": "&", '"': """, "<": "<", ">": ">"}
|
||||
{"&": "&", '"': """, "<": "<", ">": ">",
|
||||
# remove any control characters outright
|
||||
**{chr(i): "" for i in range(ord(" "))}}
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -391,13 +394,13 @@ def write_spoilers_xml(trice_dicts: Dict[str, List[Dict[str, Any]]]) -> bool:
|
|||
# Fill in set headers
|
||||
open_header(card_xml_file)
|
||||
for value in SPOILER_SETS.get():
|
||||
fill_header_sets(card_xml_file, value)
|
||||
fill_header_sets(card_xml_file, {key: (value_ + SPOILER_MARK if key == "code" else value_) for key, value_ in value.items()})
|
||||
close_header(card_xml_file)
|
||||
|
||||
# Write in all the cards
|
||||
for value in SPOILER_SETS.get():
|
||||
try:
|
||||
write_cards(card_xml_file, trice_dicts[value["code"]], value["code"])
|
||||
write_cards(card_xml_file, trice_dicts[value["code"]], value["code"] + SPOILER_MARK)
|
||||
except KeyError:
|
||||
print("Skipping " + value["code"])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user