mtgdeck package¶
Subpackages¶
Submodules¶
mtgdeck.decoder module¶
Decoder implementations for mtgdeck.
-
class
mtgdeck.decoder.AutoDecoder[source]¶ Bases:
mtgdeck.base.decoder.DecoderAuto-decoding class.
Determines the input decoding format by try-catching until it succeeds. If it fails, raises a
DecodeErrorexception.
-
class
mtgdeck.decoder.CockatriceDecoder[source]¶ Bases:
mtgdeck.base.decoder.XMLDecoderDecoding class for the Cockatrice format.
-
count= 'number'¶
-
root= 'cockatrice_deck'¶
-
section= 'zone'¶
-
-
class
mtgdeck.decoder.MagicOnlineDecoder[source]¶ Bases:
mtgdeck.base.decoder.TextDecoderDecoding class for the simple text format.
-
card= {empty rest of line}¶
-
comment= C++ style comment¶
-
count= W:(0123...)¶
-
deck= {{{C++ style comment | Group:("Sideboard")} | Group:({W:(0123...) {empty rest of line}})}}...¶
-
entry= Group:({W:(0123...) {empty rest of line}})¶
-
section= Group:("Sideboard")¶
-
setid= nested [] expression¶
-
-
class
mtgdeck.decoder.MagicWorkstationDecoder[source]¶ Bases:
mtgdeck.base.decoder.TextDecoderDecoding class for the Magic Workstation format.
-
card= {empty rest of line}¶
-
comment= C++ style comment¶
-
count= W:(0123...)¶
-
deck= {{C++ style comment | Group:({{{[Group:("SB:")] W:(0123...)} [nested [] expression]} {empty rest of line}})}}...¶
-
entry= Group:({{{[Group:("SB:")] W:(0123...)} [nested [] expression]} {empty rest of line}})¶
-
section= Group:("SB:")¶
-
setid= nested [] expression¶
-
mtgdeck.encoder module¶
Encoder implementations for mtgdeck.
-
class
mtgdeck.encoder.CockatriceEncoder[source]¶ Bases:
mtgdeck.base.encoder.XMLEncoderEncoding class for the Cockatrice format.
-
count= 'number'¶
-
root= 'cockatrice_deck'¶
-
section= 'zone'¶
-
section_name= 'main'¶
-
-
class
mtgdeck.encoder.MagicOnlineEncoder[source]¶ Bases:
mtgdeck.base.encoder.TextEncoderEncoding class for the simple text format.
This is the format that MTGO outputs. Each line has the form ‘quantity name’. An optional line containing the word ‘Sideboard’ indicates that subsequent entries are sideboard material.
-
class
mtgdeck.encoder.MagicWorkstationEncoder[source]¶ Bases:
mtgdeck.base.encoder.TextEncoderEncoding class for the Magic Workstation format.
Each line has the form ‘[SB: ]quantity [SETID ]name’, ‘[]’ meaning optional fields.
Module contents¶
Public API entry-point for mtgdeck.
-
mtgdeck.load(fin, cls=<class 'mtgdeck.decoder.AutoDecoder'>)[source]¶ Deserialize
fin(a.read()-supporting file-like object containing an MTG decklist) to a Python object.To use a custom
MTGDeckDecodersubclass, specify it with theclskwarg; otherwiseAutoDecoderis used.
-
mtgdeck.loads(string, cls=<class 'mtgdeck.decoder.AutoDecoder'>)[source]¶ Deserialize
string(astr,bytesorbytearrayinstance containing an MTG decklist) to a Python object.To use a custom
MTGDeckDecodersubclass, specify it with theclskwarg; otherwiseAutoDecoderis used.
-
mtgdeck.dump(obj, fout, cls=<class 'mtgdeck.encoder.MagicOnlineEncoder'>)[source]¶ Serialize
objas a MTG decklist formatted stream tofout(a.write()-supporting file-like object).To use a custom
Encodersubclass, specify it with theclskwarg; otherwiseEncoderis used.
-
mtgdeck.dumps(obj, cls=<class 'mtgdeck.encoder.MagicOnlineEncoder'>)[source]¶ Serialize
objto a MTG decklist formattedstr.To use a custom
Encodersubclass, specify it with theclskwarg; otherwiseEncoderis used.
-
class
mtgdeck.AutoDecoder[source]¶ Bases:
mtgdeck.base.decoder.DecoderAuto-decoding class.
Determines the input decoding format by try-catching until it succeeds. If it fails, raises a
DecodeErrorexception.
-
class
mtgdeck.MagicOnlineDecoder[source]¶ Bases:
mtgdeck.base.decoder.TextDecoderDecoding class for the simple text format.
-
card= {empty rest of line}¶
-
comment= C++ style comment¶
-
count= W:(0123...)¶
-
deck= {{{C++ style comment | Group:("Sideboard")} | Group:({W:(0123...) {empty rest of line}})}}...¶
-
entry= Group:({W:(0123...) {empty rest of line}})¶
-
section= Group:("Sideboard")¶
-
setid= nested [] expression¶
-
-
class
mtgdeck.MagicWorkstationDecoder[source]¶ Bases:
mtgdeck.base.decoder.TextDecoderDecoding class for the Magic Workstation format.
-
card= {empty rest of line}¶
-
comment= C++ style comment¶
-
count= W:(0123...)¶
-
deck= {{C++ style comment | Group:({{{[Group:("SB:")] W:(0123...)} [nested [] expression]} {empty rest of line}})}}...¶
-
entry= Group:({{{[Group:("SB:")] W:(0123...)} [nested [] expression]} {empty rest of line}})¶
-
section= Group:("SB:")¶
-
setid= nested [] expression¶
-
-
class
mtgdeck.OCTGNDecoder[source]¶ Bases:
mtgdeck.base.decoder.XMLDecoderDecoding class for the OCTGN Deck Creator format.
-
count= 'qty'¶
-
root= 'deck'¶
-
section= 'section'¶
-
-
class
mtgdeck.CockatriceDecoder[source]¶ Bases:
mtgdeck.base.decoder.XMLDecoderDecoding class for the Cockatrice format.
-
count= 'number'¶
-
root= 'cockatrice_deck'¶
-
section= 'zone'¶
-
-
class
mtgdeck.MagicOnlineEncoder[source]¶ Bases:
mtgdeck.base.encoder.TextEncoderEncoding class for the simple text format.
This is the format that MTGO outputs. Each line has the form ‘quantity name’. An optional line containing the word ‘Sideboard’ indicates that subsequent entries are sideboard material.
-
class
mtgdeck.MagicWorkstationEncoder[source]¶ Bases:
mtgdeck.base.encoder.TextEncoderEncoding class for the Magic Workstation format.
Each line has the form ‘[SB: ]quantity [SETID ]name’, ‘[]’ meaning optional fields.