示例#1
0
    def test_relational_ents_mk_tbl(self):
        ents = [{'vals' : [{'meta_instanceId': 1}], 'col' : 'table1'},
               {'vals' : [{'meta_instanceId': 1, 'col2': 2}], 'col' : 'table2'},
               {'vals' : [{'meta_instanceId': 3}], 'col' : 'table1'}]

        db.relational_ents(None, 'bob', ents)

        self.assertEqual(sorted([t.name for t in db.metadata.tables.values()]), sorted(['bob_table1', 'bob_table2']))
示例#2
0
文件: test_db.py 项目: thenav56/hfh
    def test_relational_ents_mk_tbl(self):
        ents = [{'vals': [{'meta_instanceId': 1}], 'col': 'table1'},
                {'vals': [{'meta_instanceId': 1, 'col2': 2}], 'col': 'table2'},
                {'vals': [{'meta_instanceId': 3}], 'col': 'table1'}]

        db.relational_ents(None, 'bob', ents)

        self.assertEqual(
                sorted([t.name for t in db.metadata.tables.values()]),
                sorted(['bob_table1', 'bob_table2']))
示例#3
0
文件: main.py 项目: eoglethorpe/hfh
    rel = []

    #go through all the entries for a given survey
    for sl in walk(cd).next()[1]:
        ent = _get_an_entry(join(cd, sl) + '/', surname)
        cont += [ent['content']]

    cont, rel = _break_up(cont)

    #store main entries
    logger.info('***Storing main table entries***')
    db.store(cont, ent['id'])

    logger.info('***Storing relational info***')
    #store relational entries'
    db.relational_ents(schema, surname, rel)

    #get and store OSM data
    osm.store_an_osm(cont, ent['id'])


def get_all_surveys(schema):
    """ iterate through all surveys"""
    base = DEST_LOC + DV
    surveys = [f for f in listdir(base) if not isfile(join(base, f))]
    logger.info('****Extracting the following surveys...****')
    logger.info(surveys)

    #directory structure: .../submissions/date_file/surveys/entry_id/.osm|.xml|.json

    #traverse through to get entries and their data files
示例#4
0
    rel = []

    # go through all the entries for a given survey
    for sl in walk(cd).next()[1]:
        ent = _get_an_entry(join(cd, sl) + '/', surname)
        cont += [ent['content']]

    cont, rel = _break_up(cont)

    # store main entries
    logger.info('***Storing main table entries***')
    db.store(cont, ent['id'])

    logger.info('***Storing relational info***')
    # store relational entries'
    db.relational_ents(schema, surname, rel)

    # get and store OSM data
    osm.store_an_osm(cont, ent['id'])


def get_all_surveys(schema):
    """ iterate through all surveys"""
    base = DEST_LOC + DV
    surveys = [f for f in listdir(base) if not isfile(join(base, f))]
    logger.info('****Extracting the following surveys...****')
    logger.info(surveys)

    # directory structure:
    # .../submissions/date_file/surveys/entry_id/.osm|.xml|.json