class TileFetcher: '''Base class for tile fetchers''' def __init__(self, tilemanager, *args, **kwargs): self.tilemanager = tilemanager self._init(*args, **kwargs) def _init(self): return def upkeep(self): '''Do any pending tasks, ie. saving back downloaded images.''' def has_tile(self, coords): '''Check if we can get this tile, without actually doing it''' return False def get_tile(self, coords, block = False): '''Fetch a tile described by coords. If there is something that can be done in background (ie. downloading), it is controlled by 'block'. ''' if self.has_tile(coords): return self._get_tile(coords, block) else: return None def put_tile(self, coords, image): '''Put an image back in the cache, if this class implements such a behaviour.''' self._put_tile(coords, image) def _put_tile(self, coords, image): return