Example #1
0
def load_remote_data(repo_url):
    '''
        Takes a url for a register repository
        e.g. https://github.com/openregister/registername.register.

        It will use the last item in the path to work out the register name.
        So in example above register name == registername.

        It will then load the data contained in the repository and
        load it into the register. Currently that means loading the data
        into the mongodb for the register.
    '''
    register_name = repo_url.split('/')[-1].split('.')[0]  # ouch
    print('register:', register_name)
    print('repository:', repo_url)
    register = registers.get(register_name)
    if not register:
        register = Register(register_name.capitalize(),
                            app.config['MONGO_URI'])
        registers[register_name] = register
    zip_url = '%s/archive/master.zip' % repo_url
    register.load_remote(zip_url)
Example #2
0
import application
import json

from application.registry import Register

from entry import Entry

app = application.app.test_client()
db = application.db
register = Register('testing', application.app.config['MONGO_URI'])

registry_url = 'http://openregister.org/'
field_url = 'http://testing.openregister.org/'


def setup():
    collections = db.collection_names()
    if 'testing' not in collections:
        db.create_collection('testing')

    entry = Entry()
    entry.primitive = {"id": 123, "someField": "thevalue"}
    register.put(entry)

    entry.primitive = {"id": 678, "someField": "thevalue"}
    register.put(entry)

    entry.primitive = {"id": 234, "otherField": "another value"}
    register.put(entry)

Example #3
0
def load_local_data(source):
    for name in os.listdir(source):
        path = os.path.join(source, name)
        if os.path.isdir(path):
            register = Register(name, app.config['MONGO_URI'])
            register.load(path)