示例#1
0
def sync_source(source_index_data, use_cached=True):
    if use_cached:
        filename = "samples/source/"+source_index_data["code"]+".txt"
    else:
        filename = download_source(source_index_data)
    #source_detail_file = open(filename, 'r')
    source_detail_data = source.load_file(filename)
    for d in source_detail_data['dances']:
        sync_dance(source_detail_data, d)
    query_result = db.sources.update({"index.code": source_index_data["code"]},
                                     {"index": source_index_data,
                                      "detail": source_detail_data},
                                     upsert=True)
    print(source_index_data["code"], query_result)
示例#2
0
def main(argv):
    data = source.load_file(argv[1])
    pprint(data)