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


Python OpenLibrary.autologin方法代码示例

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


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

示例1: main

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
def main():
    options, args = parse_args()

    if options.src.startswith("http://"):
        src = OpenLibrary(options.src)
    else:
        src = Disk(options.src)

    if options.dest.startswith("http://"):
        dest = OpenLibrary(options.dest)
        section = "[%s]" % web.lstrips(options.dest, "http://").strip("/")
        if section in read_lines(os.path.expanduser("~/.olrc")):
            dest.autologin()
        else:
            dest.login("admin", "admin123")
    else:
        dest = Disk(options.dest)

    for list_key in options.lists:
        copy_list(src, dest, list_key, comment=options.comment)

    keys = args
    keys = list(expand(src, keys))

    copy(src, dest, keys, comment=options.comment, recursive=options.recursive)
开发者ID:lukasklein,项目名称:openlibrary,代码行数:27,代码来源:copydocs.py

示例2: main

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
def main(server):
    ol = OpenLibrary(server)
    ol.autologin()

    volumes = ol.query({'type': '/type/volume', 'limit': False, '*': None, 'edition': {'*': None}})

    volumes = dict((v['key'], v) for v in volumes)
    editions = dict((v['edition']['key'], v['edition']) for v in volumes.values() if v['edition'])

    def make_volume(v):
        d = {}
        v.pop('edition')
        v['type'] = {'key': '/type/volume'}
        for k in ['type', 'ia_id', 'volume_number']:
            if k in v:
                d[k] = v[k]
        return d

    for e in editions.values():
        e['volumes'] = []

    for v in volumes.values():
        if v.get('edition'):
            e = editions[v.get('edition')['key']]
            e['volumes'].append(make_volume(v))

    for e in editions.values():
        e['volumes'] = sorted(e['volumes'], key=lambda v: v['volume_number'])

    print 'linking volumes to %d editions' % len(editions)
    ol.save_many(editions.values(), 'link volumes')
开发者ID:hornc,项目名称:openlibrary-1,代码行数:33,代码来源:link_volumes.py

示例3: load

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
def load():
    """Loads documents to http://0.0.0.0:8080"""
    documents = {}
    for f in find("data"):
        doc = simplejson.load(open(f))
        documents[doc['key']] = doc

    keys = topological_sort(documents.keys(), 
            get_children=lambda key: [k for k in get_references(documents[key]) if not k.startswith("/type/")])

    from openlibrary.api import OpenLibrary
    ol = OpenLibrary("http://0.0.0.0:8080")
    ol.autologin()
    print ol.save_many([documents[k] for k in keys], comment="documents copied from openlibrary.org")
开发者ID:RaceList,项目名称:openlibrary,代码行数:16,代码来源:fetch.py

示例4: main

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
def main():
    ol = OpenLibrary()
    ol.autologin()

    plugin = sys.argv[1]

    all_docs = []

    for pattern in sys.argv[2:]:
        docs = ol.query({"key~": pattern, "*": None}, limit=1000)
        all_docs.extend(docs)

    for doc in all_docs:
        doc['plugin'] = plugin

    print ol.save_many(all_docs, comment="Marked as part of %s plugin." % plugin)
开发者ID:RaceList,项目名称:openlibrary,代码行数:18,代码来源:mark-templates.py

示例5: write_to_ol

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
def write_to_ol(olkey, oljson):

    ol = OpenLibrary("http://openlibrary.org")

    # Log in [daniel, sam]
    logged_in = False
    for attempt in range(5):
        try:
            ol.autologin()
            logged_in = True
            break
        except:
            print 'ol.autologin() error; retrying'
    if not logged_in:
        sys.exit('Failed to log in.')    

    ol.save(olkey, oljson, 'Adding Table of Contents')
开发者ID:rajbot,项目名称:OLbots,代码行数:19,代码来源:tocbot.py

示例6: main

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
def main(server):
    ol = OpenLibrary(server)
    ol.autologin()

    scan_records = ol.query(type='/type/scan_record', limit=False, edition={'*': None})
    editions = (r['edition'] for r in scan_records)

    # process 1000 editions at a time.
    while True:
        chunk = take(1000, editions)
        if not chunk:
            break

        print 'linking %d editions' % len(chunk)
        
        for e in chunk:
            e['scan_records'] = [{'key': '/scan_record' + e['key']}]
            
        ol.save_many(chunk, 'link scan records')
开发者ID:RaceList,项目名称:openlibrary,代码行数:21,代码来源:link_scan_records.py

示例7: get_ol

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
def get_ol():
    ol = OpenLibrary()
    ol.autologin()
    return ol
开发者ID:digital-dreamer,项目名称:openlibrary,代码行数:6,代码来源:manage-imports.py

示例8: dict

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
         if d.get('type') == '/type/text':
             return dict(title=d['value'])
         else:
             return d

     toc = doc.get('table_of_contents')
     if toc:
          if type(toc) == dict:
               doc['table_of_contents'] = [f(x) for x in toc]
     return doc

# Log in
logged_in = False
for attempt in range(5):
    try:
        ol.autologin()
        logged_in = True
        break
    except:
        print 'ol.autologin() error; retrying'
if not logged_in:
    sys.exit('Failed to log in.')

# Go through the csv file in batches until done
batch_count = 0
done = False
while not done:
    olids = []
    ltids = []
    iddict = {}
    data = []
开发者ID:dmontalvo,项目名称:IdentifierBot,代码行数:33,代码来源:fastadder.py

示例9: main

# 需要导入模块: from openlibrary.api import OpenLibrary [as 别名]
# 或者: from openlibrary.api.OpenLibrary import autologin [as 别名]
def main(site, date=None):
    ol = OpenLibrary(site)
    ol.autologin("StatsBot")

    today = date or datetime.date.today().isoformat()
    print ol._request("/admin/stats/" + today, method='POST', data="").read()
开发者ID:RaceList,项目名称:openlibrary,代码行数:8,代码来源:updatestats.py


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