def setup(phenny): ethno_setup(phenny) #populate ethnologue codes f = iso_filename(phenny) if os.path.exists(f): try: phenny.iso_data = read_dict(f) except ValueError: print('iso database read failed, refreshing it') phenny.iso_data = scrape_wiki_codes() phenny.iso_data.update(phenny.ethno_data) write_dict(f, phenny.iso_data) else: phenny.iso_data = scrape_wiki_codes() phenny.iso_data.update(phenny.ethno_data) write_dict(f, phenny.iso_data) # Conversion hash f2 = iso_one_to_three_filename(phenny) if os.path.exists(f2): try: phenny.iso_conversion_data = read_dict(f2) except ValueError: print('iso conversion db read failed, refreshing it') phenny.iso_conversion_data = scrape_wiki_codes_convert() write_dict(f2, phenny.iso_conversion_data) else: phenny.iso_conversion_data = scrape_wiki_codes_convert() write_dict(f2, phenny.iso_conversion_data)
def setup(phenny): ethno_setup(phenny) #populate ethnologue codes f = iso_filename(phenny) if os.path.exists(f): try: phenny.iso_data = read_dict(f) except ValueError: print('iso database read failed, refreshing it') phenny.iso_data = scrape_wiki_codes() phenny.iso_data.update(phenny.ethno_data) write_dict(f, phenny.iso_data) else: phenny.iso_data = scrape_wiki_codes() phenny.iso_data.update(phenny.ethno_data) write_dict(f, phenny.iso_data)