Skip to content
This repository has been archived by the owner on Jun 22, 2022. It is now read-only.

Fix for crash when cards.xml is missing a <pt> tag #11

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

starstuffharvestingstarlight

Found while testing with a recent cards.xml. Some cards were missing the node, set P/T to (0,0) when that's the case.

Example of the error:

looking at Cardboard Carapace
Traceback (most recent call last):
File "website.py", line 50, in
for n in root.findall("./cards/card")))
File "website.py", line 50, in
for n in root.findall("./cards/card")))
File "/home/h/build/mtg-card-scan/search_card.py", line 285, in from_xml_node
p_t = node.find('pt').text.split('/')
AttributeError: 'NoneType' object has no attribute 'text'

@YenTheFirst
Copy link
Owner

In this case, 'cardboard carapace' is not actually a creature, and shouldn't have a power/toughness at all. Allowing it to be treated as a creature will probably cause unforseen issues elsewhere. It's being treated as a creature because gatherer is listing its type as the antiquated "Enchant Creature".

My current fix for this is to ignore the Unhinged and Unglued cards, since they're poorly formatted. I'll double-check the exclusion.

@starstuffharvestingstarlight
Copy link
Author

Good call, didn't trace the root cause of the error. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants