Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clarify names
Browse files Browse the repository at this point in the history
sbrunner committed Dec 18, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 9361726 commit 689a1e7
Showing 2 changed files with 17 additions and 16 deletions.
7 changes: 5 additions & 2 deletions tilecloud_chain/__init__.py
Original file line number Diff line number Diff line change
@@ -1367,16 +1367,19 @@ def imap(self, func: Any, time_message: str | None = None) -> None:
class Func:
"""Function with an additional field used to names it in timing messages."""

def __init__(self, func: Callable[[Tile], Tile], time_message: str | None) -> None:
def __init__(self, func: Callable[[Tile], Tile | None], time_message: str | None) -> None:
self.func = func
self.time_message = time_message

def __call__(self, tile: Tile) -> Tile:
def __call__(self, tile: Tile) -> Tile | None:
return self.func(tile)

def __str__(self) -> str:
return f"Func: {self.func}"

def __repr__(self):
return f"Func: {self.func!r}"

self.functions.append(Func(func, time_message))

def consume(self, test: int | None = None) -> None:
26 changes: 12 additions & 14 deletions tilecloud_chain/multitilestore.py
Original file line number Diff line number Diff line change
@@ -25,16 +25,20 @@ def _get_store(self, config_file: str, layer: str) -> TileStore | None:
self.stores[(config_file, layer)] = store
return store

def _get_store_tile(self, tile: Tile) -> TileStore | None:
"""Return the store corresponding to the tile."""
layer = tile.metadata["layer"]
config_file = tile.metadata["config_file"]
return self._get_store(config_file, layer)

def __contains__(self, tile: Tile) -> bool:
"""
Return true if this store contains ``tile``.
Arguments:
tile: Tile
"""
layer = tile.metadata["layer"]
config_file = tile.metadata["config_file"]
store = self._get_store(config_file, layer)
store = self._get_store_tile(tile)
assert store is not None
return tile in store

@@ -45,9 +49,7 @@ def delete_one(self, tile: Tile) -> Tile:
Arguments:
tile: Tile
"""
layer = tile.metadata["layer"]
config_file = tile.metadata["config_file"]
store = self._get_store(config_file, layer)
store = self._get_store_tile(tile)
assert store is not None
return store.delete_one(tile)

@@ -64,9 +66,7 @@ def put_one(self, tile: Tile) -> Tile:
Arguments:
tile: Tile
"""
layer = tile.metadata["layer"]
config_file = tile.metadata["config_file"]
store = self._get_store(config_file, layer)
store = self._get_store_tile(tile)
assert store is not None
return store.put_one(tile)

@@ -77,9 +77,7 @@ def get_one(self, tile: Tile) -> Tile | None:
Arguments:
tile: Tile
"""
layer = tile.metadata["layer"]
config_file = tile.metadata["config_file"]
store = self._get_store(config_file, layer)
store = self._get_store_tile(tile)
assert store is not None
return store.get_one(tile)

@@ -117,13 +115,13 @@ def apply(key: tuple[str, str], tiles: Iterator[Tile]) -> Iterator[Tile]:
def __str__(self) -> str:
"""Return a string representation of the object."""
stores = {str(store) for store in self.stores.values()}
keys = {f"{config_file}/{layer}" for config_file, layer in self.stores}
keys = {f"{config_file}:{layer}" for config_file, layer in self.stores}
return f"{self.__class__.__name__}({', '.join(stores)} - {', '.join(keys)})"

def __repr__(self) -> str:
"""Return a string representation of the object."""
stores = {repr(store) for store in self.stores.values()}
keys = {f"{config_file}/{layer}" for config_file, layer in self.stores}
keys = {f"{config_file}:{layer}" for config_file, layer in self.stores}
return f"{self.__class__.__name__}({', '.join(stores)} - {', '.join(keys)})"

@staticmethod

0 comments on commit 689a1e7

Please sign in to comment.