本文整理匯總了Python中ulif.openoffice.cachemanager.CacheManager.keys方法的典型用法代碼示例。如果您正苦於以下問題:Python CacheManager.keys方法的具體用法?Python CacheManager.keys怎麽用?Python CacheManager.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ulif.openoffice.cachemanager.CacheManager
的用法示例。
在下文中一共展示了CacheManager.keys方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_keys
# 需要導入模塊: from ulif.openoffice.cachemanager import CacheManager [as 別名]
# 或者: from ulif.openoffice.cachemanager.CacheManager import keys [as 別名]
def test_keys(self, cache_env):
# we can get all cache keys
cm = CacheManager(str(cache_env / "cache"))
src1 = str(cache_env / "src1.txt")
src2 = str(cache_env / "src2.txt")
result1 = str(cache_env / "result1.txt")
result2 = str(cache_env / "result2.txt")
key1 = cm.register_doc(src1, result1, 'foo')
assert list(cm.keys()) == ['737b337e605199de28b3b64c674f9422_1_1']
assert key1 == '737b337e605199de28b3b64c674f9422_1_1'
key2 = cm.register_doc(src1, result2, 'bar')
assert sorted(list(cm.keys())) == [
'737b337e605199de28b3b64c674f9422_1_1',
'737b337e605199de28b3b64c674f9422_1_2',
]
assert key2 == '737b337e605199de28b3b64c674f9422_1_2'
key3 = cm.register_doc(src2, result1, 'baz')
assert sorted(list(cm.keys())) == [
'737b337e605199de28b3b64c674f9422_1_1',
'737b337e605199de28b3b64c674f9422_1_2',
'd5aa51d7fb180729089d2de904f7dffe_1_1',
]
assert key3 == 'd5aa51d7fb180729089d2de904f7dffe_1_1'
示例2: test_keys_custom_level
# 需要導入模塊: from ulif.openoffice.cachemanager import CacheManager [as 別名]
# 或者: from ulif.openoffice.cachemanager.CacheManager import keys [as 別名]
def test_keys_custom_level(self):
# we can get all cache keys also with custom level set
cm = CacheManager(self.workdir, level=3)
key1 = cm.register_doc(self.src_path1, self.result_path1, 'foo')
self.assertEqual(
list(cm.keys()),
['737b337e605199de28b3b64c674f9422_1_1']
)
key2 = cm.register_doc(self.src_path1, self.result_path2, 'bar')
self.assertEqual(
sorted(list(cm.keys())),
['737b337e605199de28b3b64c674f9422_1_1',
'737b337e605199de28b3b64c674f9422_1_2',
]
)
key3 = cm.register_doc(self.src_path2, self.result_path1, 'baz')
self.assertEqual(
sorted(list(cm.keys())),
['737b337e605199de28b3b64c674f9422_1_1',
'737b337e605199de28b3b64c674f9422_1_2',
'd5aa51d7fb180729089d2de904f7dffe_1_1',
]
)
return
示例3: test_keys_custom_level
# 需要導入模塊: from ulif.openoffice.cachemanager import CacheManager [as 別名]
# 或者: from ulif.openoffice.cachemanager.CacheManager import keys [as 別名]
def test_keys_custom_level(self, cache_env):
# we can get all cache keys, even if a custom cache level is set
# (and keys are stored in different location).
cm = CacheManager(str(cache_env / "cache"), level=3)
src1 = str(cache_env / "src1.txt")
src2 = str(cache_env / "src2.txt")
result1 = str(cache_env / "result1.txt")
result2 = str(cache_env / "result2.txt")
key1 = cm.register_doc(src1, result1, 'foo')
assert list(cm.keys()) == ['737b337e605199de28b3b64c674f9422_1_1']
assert key1 == '737b337e605199de28b3b64c674f9422_1_1'
key2 = cm.register_doc(src1, result2, 'bar')
assert sorted(list(cm.keys())) == [
'737b337e605199de28b3b64c674f9422_1_1',
'737b337e605199de28b3b64c674f9422_1_2',
]
assert key2 == '737b337e605199de28b3b64c674f9422_1_2'
key3 = cm.register_doc(src2, result1, 'baz')
assert sorted(list(cm.keys())) == [
'737b337e605199de28b3b64c674f9422_1_1',
'737b337e605199de28b3b64c674f9422_1_2',
'd5aa51d7fb180729089d2de904f7dffe_1_1',
]
assert key3 == 'd5aa51d7fb180729089d2de904f7dffe_1_1'