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

Method fetch

cflib/crazyflie/toccache.py:62–82  ·  view source on GitHub ↗

Try to get a hit in the cache, return None otherwise

(self, crc)

Source from the content-addressed store, hash-verified

60 self._rw_cache = rw_cache
61
62 def fetch(self, crc):
63 """ Try to get a hit in the cache, return None otherwise """
64 cache_data = None
65 pattern = '%08X.json' % crc
66 hit = None
67
68 for name in self._cache_files:
69 if (name.endswith(pattern)):
70 hit = name
71
72 if (hit):
73 try:
74 cache = open(hit)
75 cache_data = json.load(cache,
76 object_hook=self._decoder)
77 cache.close()
78 except Exception as exp:
79 logger.warning('Error while parsing cache file [%s]:%s',
80 hit, str(exp))
81
82 return cache_data
83
84 def insert(self, crc, toc):
85 """ Save a new cache to file """

Callers 1

_new_packet_cbMethod · 0.80

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected