Beispiel #1
0
def gen_xml(short_set):
    ids = grab_html.read_ids(short_set)
    root = generate_base_xml(short_set)
    cards = root.find('.//cards')
    for idx, id in enumerate(ids):
        if short_set == 'UGL' and id in special.UNGLUED_TOKENS:
            print "Skipping token:", id
            continue

        print id
        sp = open_with_bs(short_set, id, 'p')
        so = open_with_bs(short_set, id, 'o')

        try:
            d = gather_data(so)
        except:
            print "Multiverse id:", id
            raise
        d['type_oracle'] = d['type']
        d['rules_oracle'] = d['rules']
        del d['type'], d['rules']
        d['type_printed'], d['rules_printed'] = extract_printed_data(sp)
        d['multiverseid'] = str(id)
        print d
        sanity.check_card_dict(d)

        add_xml_element(cards, d)
        if DEBUG and idx > 1: break # FIXME

    write_xml(short_set, root)
    print "Done"
Beispiel #2
0
def grab_images(short_set):
    """ Download all card images for the given set. """

    path = os.path.join('images', short_set)
    if not os.path.exists(path):
        os.makedirs(path)

    ids = grab_html.read_ids(short_set)
    for idx, id in enumerate(ids):
        url = IMAGE_URL % locals()
        data = tools.grab_url(url)
        print "Grabbed image: %s" % id
        write_image(short_set, id, data)