MCPcopy Index your code
hub / github.com/aws/aws-cli / __setitem__

Method __setitem__

awscli/botocore/utils.py:3973–3988  ·  view source on GitHub ↗
(self, cache_key, value)

Source from the content-addressed store, hash-verified

3971 raise KeyError(cache_key)
3972
3973 def __setitem__(self, cache_key, value):
3974 full_key = self._convert_cache_key(cache_key)
3975 try:
3976 file_content = self._dumps(value)
3977 except (TypeError, ValueError):
3978 raise ValueError(
3979 f"Value cannot be cached, must be "
3980 f"JSON serializable: {value}"
3981 )
3982 if not os.path.isdir(self._working_dir):
3983 os.makedirs(self._working_dir)
3984 with os.fdopen(
3985 os.open(full_key, os.O_WRONLY | os.O_CREAT, 0o600), 'w'
3986 ) as f:
3987 f.truncate()
3988 f.write(file_content)
3989
3990 def _convert_cache_key(self, cache_key):
3991 full_path = os.path.join(self._working_dir, cache_key + '.json')

Callers

nothing calls this directly

Calls 5

_convert_cache_keyMethod · 0.95
isdirMethod · 0.45
makedirsMethod · 0.45
openMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected