本文整理汇总了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'