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


Python SyncClient.sync方法代码示例

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


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

示例1: test_anki10_modtime

# 需要导入模块: from anki.sync import SyncClient [as 别名]
# 或者: from anki.sync.SyncClient import sync [as 别名]
def test_anki10_modtime():
    deck1 = DeckStorage.Deck()
    deck2 = DeckStorage.Deck()
    client = SyncClient(deck1)
    server = SyncServer(deck2)
    client.setServer(server)
    deck1.addModel(BasicModel())
    f = deck1.newFact()
    f['Front'] = u"foo"; f['Back'] = u"bar"
    deck1.addFact(f)
    assert deck1.cardCount == 1
    assert deck2.cardCount == 0
    client.sync()
    assert deck1.cardCount == 1
    assert deck2.cardCount == 1
    file_ = unicode(os.path.join(testDir, "importing/test10-3.anki"))
    file = "/tmp/test10-3.anki"
    shutil.copy(file_, file)
    i = anki10.Anki10Importer(deck1, file)
    i.doImport()
    client.sync()
    assert i.total == 1
    assert deck2.s.scalar("select count(*) from cards") == 2
    assert deck2.s.scalar("select count(*) from facts") == 2
    assert deck2.s.scalar("select count(*) from models") == 2
开发者ID:sanna,项目名称:libanki,代码行数:27,代码来源:test_importing.py

示例2: test_localsync_threeway

# 需要导入模块: from anki.sync import SyncClient [as 别名]
# 或者: from anki.sync.SyncClient import sync [as 别名]
def test_localsync_threeway():
    # deck1 (client) <-> deck2 (server) <-> deck3 (client)
    deck3 = DeckStorage.Deck()
    client2 = SyncClient(deck3)
    server2 = SyncServer(deck2)
    client2.setServer(server2)
    client.sync()
    client2.sync()
    # add a new question
    f = deck1.newFact()
    f['Front'] = u"a"; f['Back'] = u"b"
    f = deck1.addFact(f)
    card = f.cards[0]
    client.sync()
    assert deck1.cardCount == 6
    assert deck2.cardCount == 6
    # check it propagates from server to deck3
    client2.sync()
    assert deck3.cardCount == 6
    # delete a card on deck1
    deck1.deleteCard(card.id)
    client.sync()
    assert deck1.cardCount == 5
    assert deck2.cardCount == 5
    # make sure the delete is now propagated from the server to deck3
    client2.sync()
    assert deck3.cardCount == 5
开发者ID:jmazon,项目名称:libanki,代码行数:29,代码来源:test_sync.py


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