From 7f24e2c568c5e48af7510f1b3f5cc75f3f528362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 20 Dec 2024 10:48:46 +0100 Subject: [PATCH] Add more str and repr methods --- tilecloud_chain/__init__.py | 12 ++++++++++++ tilecloud_chain/generate.py | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/tilecloud_chain/__init__.py b/tilecloud_chain/__init__.py index cc9950671..974c67a93 100644 --- a/tilecloud_chain/__init__.py +++ b/tilecloud_chain/__init__.py @@ -1475,6 +1475,12 @@ def __call__(self, tile: Tile | None = None) -> Tile | None: self.nb += 1 return tile + def __str__(self) -> str: + return f"Count: {self.nb}" + + def __repr__(self) -> str: + return f"Count: {self.nb}" + class CountSize: """Count the number of generated tile and measure the total generated size.""" @@ -1492,6 +1498,12 @@ def __call__(self, tile: Tile | None = None) -> Tile | None: self.size += len(tile.data) return tile + def __str__(self) -> str: + return f"CountSize: {self.nb} {self.size}" + + def __repr__(self) -> str: + return f"CountSize: {self.nb} {self.size}" + class HashDropper: """ diff --git a/tilecloud_chain/generate.py b/tilecloud_chain/generate.py index 649026d86..050fcab9f 100644 --- a/tilecloud_chain/generate.py +++ b/tilecloud_chain/generate.py @@ -77,6 +77,12 @@ def __call__(self, tile: Tile) -> Tile: return tile + def __str__(self) -> str: + return self.__class__.__name__ + + def __repr__(self) -> str: + return self.__str__() + class Generate: """Generate the tiles, generate the queue, ..."""