json.dump(mtgs, outfile, sort_keys=True, indent=2, separators=(',', ': ')) def save_errorlog(errorlog): fixederrors = [] unfixederrors = [] for error in errorlog: if 'fixed' in error: fixederrors.append(error) else: unfixederrors.append(error) errorlog = {"unfixed": unfixederrors, "fixed": fixederrors} with open('out/errors.json', 'w') as outfile: json.dump(errorlog, outfile, sort_keys=True, indent=2, separators=(',', ': ')) if __name__ == '__main__': AllSets = spoilers.get_allsets() mtgs = spoilers.scrape_mtgs('http://www.mtgsalvation.com/spoilers.rss') mtgs = spoilers.parse_mtgs(mtgs) mtgs = spoilers.correct_cards(mtgs, manual_cards, card_corrections, delete_cards) #errorlog.append(temperror) #scryfall = spoilers.get_scryfall('https://api.scryfall.com/cards/search?q=++e:' + setinfos['setname'].lower()) mtgs = spoilers.get_image_urls(mtgs, presets['isfullspoil'], setinfos['setname'], setinfos['setlongname'], setinfos['setsize']) #errorlog.append(temperror) [mtgs, errors] = spoilers.errorcheck(mtgs) errorlog += errors spoilers.write_xml(mtgs, setinfos['setname'], setinfos['setlongname'], setinfos['setreleasedate']) mtgs = spoilers.add_headers(mtgs, setinfos) AllSets = spoilers.make_allsets(AllSets, mtgs, setinfos['setname']) if 'masterpieces' in setinfos: masterpieces = spoilers.make_masterpieces(setinfos['masterpieces'], AllSets, mtgs) [masterpieces, errors] = spoilers.errorcheck(masterpieces)
try: xml_schema.assert_(xml_doc) except: xsd_errors = xml_schema.error_log print("Errors validating XML file " + file + " against XSD:") for error in xsd_errors: print(error) sys.exit("Error: " + file + " does not pass Cockatrice XSD validation.") return False return True if __name__ == '__main__': parseargs() AllSets = spoilers.get_allsets() # get AllSets from mtgjson combinedjson = {} noCards = [] del AllSets['RNA'] for setinfo in setinfos: if setinfo['code'] in AllSets: print("Found " + setinfo['code'] + " set from set_info.yml in MTGJSON, not adding it") continue print("Handling {}".format(setinfo['code'])) if presets['oldRSS'] or 'noRSS' in setinfo and setinfo['noRSS']: mtgs = {"cards": []} else: mtgs = mtgs_scraper.scrape_mtgs( 'http://www.mtgsalvation.com/spoilers.rss'