MCPcopy Create free account
hub / github.com/bitcraze/crazyflie-lib-python / insert

Method insert

cflib/crazyflie/toccache.py:84–99  ·  view source on GitHub ↗

Save a new cache to file

(self, crc, toc)

Source from the content-addressed store, hash-verified

82 return cache_data
83
84 def insert(self, crc, toc):
85 """ Save a new cache to file """
86 if self._rw_cache:
87 try:
88 filename = '%s/%08X.json' % (self._rw_cache, crc)
89 cache = open(filename, 'w')
90 cache.write(json.dumps(toc, indent=2,
91 default=self._encoder))
92 cache.close()
93 logger.info('Saved cache to [%s]', filename)
94 self._cache_files += [filename]
95 except Exception as exp:
96 logger.warning('Could not save cache to file [%s]: %s',
97 filename, str(exp))
98 else:
99 logger.warning('Could not save cache, no writable directory')
100
101 def _encoder(self, obj):
102 """ Encode a toc element leaf-node """

Callers 1

_new_packet_cbMethod · 0.80

Calls 2

writeMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected