PennyDreadfulMTG / gatherling_fork

This is an archived repo. Check https://github.com/PennyDreadfulMTG/gatherling instead.
https://github.com/PennyDreadfulMTG/gatherling
MIT License
8 stars 5 forks source link

maybe accept .dek - difference from league is confusing #158

Closed vorpal-buildbot closed 5 years ago

vorpal-buildbot commented 5 years ago

Reported on Discord by bakert#2193

stash86 commented 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

bakert commented 5 years ago

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 .

stash86 commented 5 years ago

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.