Beispiel #1
0
def test():
    if os.path.exists(filename):
        os.remove(filename)

    mdb = MicroDB(filename, testpartition_keys)
    mdb.erase_all()
    mdb = MicroDB(filename, testpartition_keys)
    for d in test_data:
        mdb.upsert(d)
    mdb.save()
    mdb.pprint_all()

    mdb2 = MicroDB(filename, testpartition_keys)
    for d in mdb2.all():
        print(d)
    mdb2.save_as_grid()
    mdb3 = MicroDB(filename, testpartition_keys)
    for d in mdb3.all():
        print(d)
    mdb4 = MicroDB(filename, testpartition_keys)
    mdb4.upsert({
        'job': 'study',
        'name': 'Bob',
        'status': 'undone',
        'extra-info': 'hogehoge'
    })
    try:
        mdb4.save_as_grid()
    except Exception as e:
        print(e)
    mdb4.save()
    mdb4
def save_all_repos():
    all_repos = get_all_repos()
    all_repos = trim_repos(all_repos)
    all_repos = exclude_no_thanks(all_repos)
    mdb = MicroDB(jsons_dir + 'repos.json', partition_keys=[
        'full_name',
    ])
    for repo in all_repos:
        mdb.upsert(dictionary=repo)
    mdb.save()