Skip to content
This repository
tree: 484667bfef
Fetching contributors…

Cannot retrieve contributors at this time

file 37 lines (28 sloc) 1.061 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#!/usr/bin/env python

import codecs
import json
import os
from os.path import join, exists

from makerbase.models import *


for dirname in ('makers', 'projects'):
    if not exists(dirname):
        os.mkdir(dirname)

for key in Maker.get_bucket().get_keys():
    maker = Maker.get(key)

    filename = join('makers', maker._id + '.json')
    with codecs.open(filename, 'w', 'utf-8') as f:
        data = maker.get_api_data(include_links=False)
        json.dump(data, f, indent=4, sort_keys=True)

for key in Project.get_bucket().get_keys():
    project = Project.get(key)

    filename = join('projects', project._id + '.json')
    with codecs.open(filename, 'w', 'utf-8') as f:
        parties = list()
        for party in project.parties:
            data = party.get_api_data(include_links=False)
            del data['id']
            data['maker'] = party.maker._id
            parties.append(data)

        data = project.get_api_data(include_links=False)
        data['participations'] = parties
        json.dump(data, f, indent=4, sort_keys=True)
Something went wrong with that request. Please try again.