Closed vorpal-buildbot closed 5 years ago
this one can be done easily. I can change it to xml, then use simplexml parser for it. gonna work on this later
All we do in the python is:
# Parse a deck in the Magic Online XML .dek format or raise an
InvalidDataException.
def parse_xml(s: str) -> DecklistType:
d: DecklistType = {'maindeck': {}, 'sideboard': {}}
try:
doc = untangle.parse(s)
for c in doc.Deck.Cards:
section = 'sideboard' if c['Sideboard'] == 'true' else
'maindeck'
d[section][c['Name']] = d[section].get(c['Name'], 0) +
int(c['Quantity'])
return d
except xml.sax.SAXException as e: # type: ignore
raise InvalidDataException(e)
except AttributeError as e:
raise InvalidDataException(e) # Not valid MTGO .deck format
On Fri, Feb 1, 2019 at 7:13 PM Stefano Ariestasia notifications@github.com wrote:
this one can be done easily. I can change it to xml, then use simplexml parser for it. gonna work on this later
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PennyDreadfulMTG/gatherling/issues/158#issuecomment-459930219, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAGBaHem_ZtS2uHGbcIw4vIc0tNcaFfks5vJQJPgaJpZM4XYXce .
Got this done just now. Just need to open a new PR
On 2 Feb 2019, at 13.00, Thomas David Baker notifications@github.com wrote:
All we do in the python is:
# Parse a deck in the Magic Online XML .dek format or raise an
InvalidDataException.
def parse_xml(s: str) -> DecklistType:
d: DecklistType = {'maindeck': {}, 'sideboard': {}}
try:
doc = untangle.parse(s)
for c in doc.Deck.Cards:
section = 'sideboard' if c['Sideboard'] == 'true' else
'maindeck'
d[section][c['Name']] = d[section].get(c['Name'], 0) +
int(c['Quantity'])
return d
except xml.sax.SAXException as e: # type: ignore
raise InvalidDataException(e)
except AttributeError as e:
raise InvalidDataException(e) # Not valid MTGO .deck format
On Fri, Feb 1, 2019 at 7:13 PM Stefano Ariestasia notifications@github.com wrote:
this one can be done easily. I can change it to xml, then use simplexml parser for it. gonna work on this later
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/PennyDreadfulMTG/gatherling/issues/158#issuecomment-459930219, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAGBaHem_ZtS2uHGbcIw4vIc0tNcaFfks5vJQJPgaJpZM4XYXce .
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
Reported on Discord by bakert#2193