mtgdeck package¶
Subpackages¶
Submodules¶
mtgdeck.decoder module¶
Decoder implementations for mtgdeck.
-
class
mtgdeck.decoder.
AutoDecoder
[source]¶ Bases:
mtgdeck.base.decoder.Decoder
Auto-decoding class.
Determines the input decoding format by try-catching until it succeeds. If it fails, raises a
DecodeError
exception.
-
class
mtgdeck.decoder.
CockatriceDecoder
[source]¶ Bases:
mtgdeck.base.decoder.XMLDecoder
Decoding class for the Cockatrice format.
-
count
= 'number'¶
-
root
= 'cockatrice_deck'¶
-
section
= 'zone'¶
-
-
class
mtgdeck.decoder.
MagicOnlineDecoder
[source]¶ Bases:
mtgdeck.base.decoder.TextDecoder
Decoding 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.TextDecoder
Decoding 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.XMLEncoder
Encoding class for the Cockatrice format.
-
count
= 'number'¶
-
root
= 'cockatrice_deck'¶
-
section
= 'zone'¶
-
section_name
= 'main'¶
-
-
class
mtgdeck.encoder.
MagicOnlineEncoder
[source]¶ Bases:
mtgdeck.base.encoder.TextEncoder
Encoding 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.TextEncoder
Encoding 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
MTGDeckDecoder
subclass, specify it with thecls
kwarg; otherwiseAutoDecoder
is used.
-
mtgdeck.
loads
(string, cls=<class 'mtgdeck.decoder.AutoDecoder'>)[source]¶ Deserialize
string
(astr
,bytes
orbytearray
instance containing an MTG decklist) to a Python object.To use a custom
MTGDeckDecoder
subclass, specify it with thecls
kwarg; otherwiseAutoDecoder
is used.
-
mtgdeck.
dump
(obj, fout, cls=<class 'mtgdeck.encoder.MagicOnlineEncoder'>)[source]¶ Serialize
obj
as a MTG decklist formatted stream tofout
(a.write()
-supporting file-like object).To use a custom
Encoder
subclass, specify it with thecls
kwarg; otherwiseEncoder
is used.
-
mtgdeck.
dumps
(obj, cls=<class 'mtgdeck.encoder.MagicOnlineEncoder'>)[source]¶ Serialize
obj
to a MTG decklist formattedstr
.To use a custom
Encoder
subclass, specify it with thecls
kwarg; otherwiseEncoder
is used.
-
class
mtgdeck.
AutoDecoder
[source]¶ Bases:
mtgdeck.base.decoder.Decoder
Auto-decoding class.
Determines the input decoding format by try-catching until it succeeds. If it fails, raises a
DecodeError
exception.
-
class
mtgdeck.
MagicOnlineDecoder
[source]¶ Bases:
mtgdeck.base.decoder.TextDecoder
Decoding 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.TextDecoder
Decoding 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.XMLDecoder
Decoding class for the OCTGN Deck Creator format.
-
count
= 'qty'¶
-
root
= 'deck'¶
-
section
= 'section'¶
-
-
class
mtgdeck.
CockatriceDecoder
[source]¶ Bases:
mtgdeck.base.decoder.XMLDecoder
Decoding class for the Cockatrice format.
-
count
= 'number'¶
-
root
= 'cockatrice_deck'¶
-
section
= 'zone'¶
-
-
class
mtgdeck.
MagicOnlineEncoder
[source]¶ Bases:
mtgdeck.base.encoder.TextEncoder
Encoding 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.TextEncoder
Encoding class for the Magic Workstation format.
Each line has the form ‘[SB: ]quantity [SETID ]name’, ‘[]’ meaning optional fields.