本文整理汇总了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
示例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',
示例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']: