Exemplo n.º 1
0
def lang():
    f = 'original_languages'
    queue = []
    for w in iter_works([f, 'title']):
        if f in w and w[f]:
            continue
        q = {
            'type': '/type/edition',
            'works': w['key'],
            'languages': None,
            'title': None,
            'title_prefix': None
        }
        editions = [e for e in query_iter(q) if e['languages']]
        title = mk_norm(w['title'])
        if not editions or any(len(e['languages']) != 1 for e in editions):
            continue
        lang = [
            e['languages'][0]['key'] for e in editions
            if mk_norm(get_title(e)) == title
        ]
        if len(lang) < 2:
            continue
        first = lang[0]
        if any(l != first for l in lang):
            continue
        print((w['key'], repr(w['title']), first, len(lang)))
        q = {'key': w['key'], f: {'connect': 'update_list', 'value': [first]}}
        queue.append(q)
        if len(queue) == 200:
            print(ol.write(queue, comment='add original language'))
            queue = []
    print(ol.write(queue, comment='add original language'))
Exemplo n.º 2
0
def lang():
    f = 'original_languages'
    queue = []
    for w in iter_works([f, 'title']):
        if f in w and w[f]:
            continue
        q = {
            'type':'/type/edition',
            'works': w['key'],
            'languages': None,
            'title': None,
            'title_prefix': None
        }
        editions = [e for e in query_iter(q) if e['languages']]
        title = mk_norm(w['title'])
        if not editions or any(len(e['languages']) != 1 for e in editions):
            continue
        lang = [e['languages'][0]['key'] for e in editions if mk_norm(get_title(e)) == title]
        if len(lang) < 2:
            continue
        first = lang[0]
        if any(l != first for l in lang):
            continue
        print w['key'], `w['title']`, first, len(lang)
        q = {
            'key': w['key'],
            f: { 'connect': 'update_list', 'value': [first]}
        }
        queue.append(q)
        if len(queue) == 200:
            print ol.write(queue, comment='add original language')
            queue = []
    print ol.write(queue, comment='add original language')
Exemplo n.º 3
0
    q[k] = None

for w in query_iter(q):
    wkey = w['key']
    titles = set([w['title']])
    q = {'type': '/type/edition', 'works': wkey}
    for k in 'title', 'title_prefix', 'key', 'authors':
        q[k] = None

    wakey = w['authors'][0]['key']
    work_author = withKey(wakey)

    for e in query_iter(q):
        if not e.get('title', None):
            continue
        titles.update([get_title(e), e['title']])

    found = []
    for title in titles:
        found += list(other_editions(title, wkey, work_author))

    if not found:
        continue
    print w
    print titles
    print wakey + ':', fmt_author(work_author)
    for e, a in found:
        print '  ', a['key'] + ": ", fmt_author(a)
        print '  ', e
    print
Exemplo n.º 4
0
    q[k] = None

for w in query_iter(q):
    wkey = w['key']
    titles = set([w['title']])
    q = { 'type': '/type/edition', 'works': wkey }
    for k in 'title', 'title_prefix', 'key', 'authors':
        q[k] = None

    wakey = w['authors'][0]['key']
    work_author = withKey(wakey)

    for e in query_iter(q):
        if not e.get('title', None): 
            continue
        titles.update([get_title(e), e['title']])

    found = []
    for title in titles:
        found += list(other_editions(title, wkey, work_author))

    if not found:
        continue
    print w
    print titles
    print wakey + ':', fmt_author(work_author)
    for e, a in found:
        print '  ', a['key'] + ": ", fmt_author(a)
        print '  ', e
    print