Ejemplo n.º 1
0
def main():  # pragma: no cover
    configure_logging()

    for spec in [
        (load_societies, csv_items(*csv_names('%s_societies.csv'))),
        (load_regions, data_path('geo', 'level2.json')),
        (society_locations, csv_items('society_locations.csv')),
        (load_vars, csv_items(*csv_names('%sVariableList.csv'))),
        (load_codes, csv_items(*csv_names('%sCodeDescriptions.csv'))),
        # Linking Societies to Languoids
        (
            xd_to_language,
            csv_items('xd_id_to_language.csv'), csv_items('glottolog.csv')),
        (
            load_references,
            csv_items('ReferenceMapping.csv', 'BinfordReferenceMapping.csv')),
        (load_data, csv_items(*csv_names('%s_data.csv'))),
        (load_environmental_var, csv_items('environmentalVariableList.csv')),
        (load_environmental, csv_items('environmental_data.csv')),
        (load_trees, data_path('trees')),
        (tree_names, data_path('csv')),
        (prune_trees,),
    ]:
        with transaction.atomic():
            loader, args = spec[0], spec[1:]
            print loader.__name__, '...'
            start = time()
            res = loader(*args)
            print res, 'loaded in', time() - start, 'secs'
Ejemplo n.º 2
0
def run(mode, *fnames):  # pragma: no cover
    configure_logging()

    if mode == 'geo':
        return load_regions(fnames[0])
    if mode == 'tree':
        return load_trees(fnames[0])
    if mode == 'xd_lang':
        return xd_to_language(csv_dict_reader(fnames[0]), csv_dict_reader(fnames[1]))
    if mode in ITEM_LOADER:
        return ITEM_LOADER[mode](chain(*map(csv_dict_reader, fnames)))
    raise ValueError(mode)