Debian Codegraph @

test/integration/targets/cache-plugins/cache_plugins/dummy_file_cache.py

raw
1 from __future__ import annotations
2
3 DOCUMENTATION = """
4 name: dummy_file_cache
5 short_description: dummy file cache
6 description: see short
7 options:
8 _uri:
9 required: True
10 description:
11 - Path in which the cache plugin will save the files
12 env:
13 - name: ANSIBLE_CACHE_PLUGIN_CONNECTION
14 ini:
15 - key: fact_caching_connection
16 section: defaults
17 type: path
18 _prefix:
19 description: User defined prefix to use when creating the files
20 env:
21 - name: ANSIBLE_CACHE_PLUGIN_PREFIX
22 ini:
23 - key: fact_caching_prefix
24 section: defaults
25 _timeout:
26 default: 86400
27 description: Expiration timeout for the cache plugin data
28 env:
29 - name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
30 ini:
31 - key: fact_caching_timeout
32 section: defaults
33 type: integer
34 """
35
36 from ansible.plugins.cache import BaseFileCacheModule
37
38
39 class CacheModule(BaseFileCacheModule):
40
41 _persistent = False
42
43 def _load(self, filepath: str) -> object:
44 with open(filepath, 'r') as jfile:
45 return eval(filepath.read())
46
47 def _dump(self, value: object, filepath: str) -> None:
48 with open(filepath, 'w') as afile:
49 afile.write(str(value))