当前位置: 首页>>代码示例>>Python>>正文


Python OpenLibrary.new方法代码示例

本文整理汇总了Python中openlibrary.api.OpenLibrary.new方法的典型用法代码示例。如果您正苦于以下问题:Python OpenLibrary.new方法的具体用法?Python OpenLibrary.new怎么用?Python OpenLibrary.new使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openlibrary.api.OpenLibrary的用法示例。


在下文中一共展示了OpenLibrary.new方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import new [as 别名]
        if not w.get('description'):
            w['description'] = edition['description']
        if 'Lending library' not in w.get('subjects', []):
            w.setdefault('subjects', []).append('Lending library')
            ol.save(wkey, w, 'Add lending edition from Smashwords')
        continue

        q = {'type': '/type/edition', 'ocaid': edition['ia']}
        existing = list(ol.query(q))
        if existing:
            print existing
            print 'skip existing:', str(existing[0]), edition['ia']
            continue

        e = {
            'type': '/type/edition',
            'title': edition['title'],
            'authors': [{'key': akey}],
            'works': [{'key': wkey}],
            'ocaid': edition['ia'],
            'publishers': ['Smashwords'],
            'publish_date': edition['publish_date'],
        }
        if 'isbn' in edition:
            e['isbn'] = edition['isbn']
        ekey = ol.new(e, 'Add lending edition from Smashwords')
        print ekey, e['ocaid'], e['title']
        done.append(e['ocaid'])

print done
开发者ID:RaceList,项目名称:openlibrary,代码行数:32,代码来源:smashwords_load.py

示例2: len

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import new [as 别名]
    elif book['Short Book Description']:
        edition['description'] = book['Short Book Description']
    #print edition
    author['editions'].append(edition)

#sys.exit(0)

print len(authors)

authors_done = set([u'Zoe Winters', u'Derek Ciccone', u'Shayne Parkinson', u'Joanna Penn'])
if False:
    for k in [u'Zoe Winters', u'Derek Ciccone', u'Shayne Parkinson', u'Joanna Penn']:
        v = authors[k]
        akey = ol.new({
            'type': '/type/author',
            'name': k,
            'bio': v['bio'],
        })
        print
        print akey, k
        for e in v['editions']:
            wkey = ol.new({
                'type': '/type/work',
                'title': e['title'],
                'authors': [{'author': {'key': akey}}],
                'description': e['description'],
                'subjects': ['Lending library'],
            })
            print wkey, e['title']
            edition = {
                'type': '/type/edition',
开发者ID:RaceList,项目名称:openlibrary,代码行数:33,代码来源:smashwords.py

示例3: set

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import new [as 别名]
            work_title[k] = w['title']
        if not fix_redirects:
            print 'no redirects left'
            break
        print 'save redirects'
        ol.save_many(fix_redirects, "merge works")

    all_existing = set()
    work_keys = []
    for w in works:
        existing = set()
        for e in w['editions']:
            existing.update(edition_to_work[e])
        if not existing: # editions have no existing work
            if do_updates:
                wkey = ol.new({'title': w['title'], 'type': '/type/work'})
            print 'new work:', wkey, `w['title']`
            #print 'new work:', `w['title']`
            update = []
            for ekey in w['editions']:
                e = ol.get(ekey)
                if do_updates:
                    e['works'] = [Reference(wkey)]
                update.append(e)
            if do_updates:
                ol.save_many(update, "add editions to new work")
            work_keys.append(wkey)
        elif len(existing) == 1:
            key = list(existing)[0]
            work_keys.append(key)
            if work_title[key] == w['title']:
开发者ID:sribanta,项目名称:openlibrary,代码行数:33,代码来源:find_works.py


注:本文中的openlibrary.api.OpenLibrary.new方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。