Пример #1
0
def main(argv):
    if not argv.card:
        print(u"You must specify a card.")
        sys.exit()
    else:
        try:
            if argv.rulings:
                card_obj = find_card(u" ".join(argv.card))
                pp = pprint.PrettyPrinter(indent=4)
                pp.pprint(card_obj.get_rulings())
            elif argv.flavor:
                card_obj = find_card(u" ".join(argv.card))
                pp = pprint.PrettyPrinter(indent=4)
                pp.pprint(card_obj.get_flavor_text())
            elif argv.eprice:
                card_obj = find_card(u" ".join(argv.card))
                print(card_obj.get_mtgoprice())
            elif argv.legality:
                card_obj = find_card(u" ".join(argv.card))
                print(card_obj.get_legality())
            elif argv.printed:
                card_obj = find_card(u" ".join(argv.card))
                print(card_obj.get_printed_text())
            elif argv.set:
                models.setup()
                set_obj = find_expansion(u" ".join(argv.card))
                models.close()
                print(set_obj)
            else:
                card_obj = find_card(u" ".join(argv.card))
                print(card_obj.get_card_text())
                type(card_obj.name)
        except CardNotFoundError as e:
            print(u"Could not find the card: " + unicode(e))
Пример #2
0
def main(argv):
    if not argv.card:
        print(u"You must specify a card.")
        sys.exit()
    else:
        try:
            if argv.rulings:
                card_obj = find_card(u" ".join(argv.card))
                pp = pprint.PrettyPrinter(indent=4)
                pp.pprint(card_obj.get_rulings())
            elif argv.flavor:
                card_obj = find_card(u" ".join(argv.card))
                pp = pprint.PrettyPrinter(indent=4)
                pp.pprint(card_obj.get_flavor_text())
            elif argv.eprice:
                card_obj = find_card(u" ".join(argv.card))
                print(card_obj.get_mtgoprice())
            elif argv.legality:
                card_obj = find_card(u" ".join(argv.card))
                print(card_obj.get_legality())
            elif argv.printed:
                card_obj = find_card(u" ".join(argv.card))
                print(card_obj.get_printed_text())
            elif argv.set:
                models.setup()
                set_obj = find_expansion(u" ".join(argv.card))
                models.close()
                print(set_obj)
            else:
                card_obj = find_card(u" ".join(argv.card))
                print(card_obj.get_card_text())
                type(card_obj.name)
        except CardNotFoundError as e:
            print(u"Could not find the card: " + unicode(e))
Пример #3
0
def parse_mtgojson(file_location, argv):
    with open(file_location, 'r') as json_file:
        file_json = json.loads(json_file.read().decode('utf-8'))
    models.setup()
    if argv.set:
        _parse_set(file_json)
    else:
        _parse_file(file_json)
    models.close()
Пример #4
0
def parse_mtgojson(file_location, argv):
    with open(file_location, 'r') as json_file:
        file_json = json.loads(json_file.read().decode('utf-8'))
    models.setup()
    if argv.set:
        _parse_set(file_json)
    else:
        _parse_file(file_json)
    models.close()
Пример #5
0
                        "--rulings",
                        action="store_true",
                        help="Get the rulings for the specified card.")
    parser.add_argument("-e",
                        "--eprice",
                        action="store_true",
                        help="Get the MTGO price for the specified card.")
    parser.add_argument("-t",
                        "--text",
                        action="store_true",
                        help="Get the text for a specific card.")
    parser.add_argument("-f",
                        "--flavor",
                        action="store_true",
                        help="Get the flavor texts for a specific card")
    parser.add_argument("-s",
                        "--set",
                        action="store_true",
                        help="Get the set name for a specific code.")
    parser.add_argument("-p",
                        "--printed",
                        action="store_true",
                        help="Get the text originally printed on the card.")
    parser.add_argument("-l",
                        "--legality",
                        action="store_true",
                        help="Get the format legality for the specified card.")
    args = parser.parse_args()
    main(args)
    models.close()
Пример #6
0
'''
This file adds expansions that are used by MTGOtraders.

Adds several expansions that exist for card pricing but not for cards.
As well, it adds serveral set abbreviations that do not exist.

Author: John Cleaver <*****@*****.**>
license: BSD 3-Clause
'''

import card as mtgcard
from card_database import models

expansions = {
    u"ULG": u"UL",
    u"UDS": u"UD"
}


models.setup()
promo = models.Expansion(name=u"Promotional",
                         abbreviation=u"PRM",
                         )
for k, v in expansions.iteritems():
    mtgcard.find_expansion(k).mtgo_code = v
models.close()