Example #1
0
def retrieve_link(lang, code_type, code):
    if lang == 'data' or lang == 'wikidata':
        res_type = 'data'
        other_type = 'pages'
    else:
        res_type = 'pages'
        other_type = 'data'

    code = code.replace('/', '\\')

    ids = database.query_code(code_type, code)

    title = None
    if ids and ids[IDS[res_type]]:
        return (database.retrieve_from(code_type, res_type, code)['title'],
                res_type,
                title
                )
    else:
        retrieve = database.retrieve_from(code_type, other_type, code)
        if retrieve:
            linked = retrieve['linked']
            title = retrieve['title']
            if linked:
                return (database.query_id(res_type, linked)['title'],
                        other_type,
                        title
                        )
Example #2
0
def get_items_to_update(table, items):
    logger.debug('no. of items: {no}'.format(no=len(items)))

    items_to_get = []
    for item in items:
        item['source'] = table
        data = database.query_id(table, item['pageid'])
        if data is None:
            items_to_get.append(item)
        else:
            if data['id'] != item['pageid']:
                touched = __touched(item['touched'])
                if touched > data['touched']:
                    items_to_get.append(item)

    return items_to_get