コード例 #1
0
ファイル: filesystem.py プロジェクト: camptocamp/tilecloud
 def get_one(self, tile: Tile) -> Optional[Tile]:
     try:
         filename = self.tilelayout.filename(tile.tilecoord, tile.metadata)
     except Exception as e:
         tile.error = e
         return tile
     try:
         with open(filename, "rb") as file:
             tile.data = file.read()
         if self.content_type is not None:
             tile.content_type = self.content_type
         return tile
     except OSError as e:
         if e.errno == errno.ENOENT:
             return None
         else:
             raise
コード例 #2
0
 def __call__(self, tile: Tile) -> Tile:
     assert tile.data is not None
     image = PIL.Image.open(BytesIO(tile.data))
     for tilestore in self.tilestores:
         t = tilestore.get_one(Tile(tile.tilecoord))
         if t is not None:
             assert t.data is not None
             image2 = PIL.Image.open(BytesIO(t.data))
             image.paste(image2, None, image2)
     content_type = self.content_type
     if content_type is None:
         content_type = tile.content_type
     assert content_type is not None
     bytes_io = BytesIO()
     image.save(bytes_io, FORMAT_BY_CONTENT_TYPE[content_type], **self.kwargs)
     tile.content_type = content_type
     tile.data = bytes_io.getvalue()
     return tile
コード例 #3
0
 def get_one(self, tile: Tile) -> Optional[Tile]:
     flags, value, cas = self.client.get(self.tilelayout.filename(tile.tilecoord, tile.metadata))
     tile.memcached_flags = flags  # type: ignore
     tile.data = value
     tile.memcached_cas = cas  # type: ignore
     return tile
コード例 #4
0
 def get_one(self, tile: Tile) -> Tile:
     tile.data = None
     return tile
コード例 #5
0
ファイル: gzip_.py プロジェクト: camptocamp/tilecloud
 def __call__(self, tile: Tile) -> Tile:
     assert tile.data is not None
     if tile.content_encoding == "gzip":
         tile.content_encoding = None
         tile.data = GzipFile(fileobj=BytesIO(tile.data)).read()
     return tile