From 8928816605cb8b795674383600a29a17719a4962 Mon Sep 17 00:00:00 2001 From: Abdelaziz Elrashed Date: Fri, 9 Aug 2024 04:47:15 +0300 Subject: [PATCH] =?UTF-8?q?-=20=D8=A5=D8=B6=D8=A7=D9=81=D8=A9=20=D9=87?= =?UTF-8?q?=D9=8A=D9=83=D9=84=D8=A9=20=D8=A8=D9=8A=D8=A7=D9=86=D8=A7=D8=AA?= =?UTF-8?q?=20=D9=84=D8=A7=D8=AD=D8=B5=D8=A7=D8=A6=D9=8A=D8=A7=D8=AA=20?= =?UTF-8?q?=D9=85=D8=B3=D8=A7=D8=AD=D8=A9=20=D8=A7=D9=84=D9=85=D9=84=D9=81?= =?UTF-8?q?=20=D9=88=D8=A7=D9=84=D8=B0=D8=A7=D9=83=D8=B1=D8=A9=20=D8=A7?= =?UTF-8?q?=D9=84=D9=85=D8=B3=D8=AA=D8=AE=D8=AF=D9=85=D8=A9=20=D9=84=D9=82?= =?UTF-8?q?=D8=A7=D8=B9=D8=AF=D8=A9=20=D8=A7=D9=84=D8=A8=D9=8A=D8=A7=D9=86?= =?UTF-8?q?=D8=A7=D8=AA.=20-=20=D8=A5=D8=B6=D8=A7=D9=81=D8=A9=20=D8=AE?= =?UTF-8?q?=D9=8A=D8=A7=D8=B1=20=D9=84=D8=A5=D9=85=D9=83=D8=A7=D9=86=D9=8A?= =?UTF-8?q?=D8=A9=20=D8=AA=D8=AC=D8=A7=D9=87=D9=84=20=D8=AD=D8=B3=D8=A7?= =?UTF-8?q?=D8=A8=20=D8=A7=D9=84=D8=B0=D8=A7=D9=83=D8=B1=D8=A9=20=D8=A7?= =?UTF-8?q?=D9=84=D8=B9=D8=B4=D9=88=D8=A7=D8=A6=D9=8A=D8=A9=20=D9=84=D9=82?= =?UTF-8?q?=D8=A7=D8=B9=D8=AF=D8=A9=20=D8=A7=D9=84=D8=A8=D9=8A=D8=A7=D9=86?= =?UTF-8?q?=D8=A7=D8=AA.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 2 +- setup.py | 2 +- zakat/zakat_tracker.py | 25 ++++++++++++++++++++++--- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 6fdf73d..bfe5e75 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = 'zakat' -version = '0.2.93' +version = '0.2.94' authors = [ { name='Abdelaziz Elrashed Elshaikh Mohamed', email='aeemh.sdn@gmail.com' }, ] diff --git a/setup.py b/setup.py index fd96b27..127439a 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='zakat', - version='0.2.93', + version='0.2.94', description='A Python Library for Islamic Financial Management.', author='Abdelaziz Elrashed Elshaikh Mohamed', author_email='aeemh.sdn@gmail.com', diff --git a/zakat/zakat_tracker.py b/zakat/zakat_tracker.py index 81ddedf..2852ed3 100644 --- a/zakat/zakat_tracker.py +++ b/zakat/zakat_tracker.py @@ -220,7 +220,7 @@ def Version() -> str: Returns: str: The current version of the software. """ - return '0.2.93' + return '0.2.94' @staticmethod def ZakatCut(x: float) -> float: @@ -563,7 +563,23 @@ def vault(self) -> dict: """ return self._vault.copy() - def stats(self) -> dict[str, tuple]: + def stats_init(self) -> dict[str, tuple[int, str]]: + """ + Initialize and return a dictionary containing initial statistics for the ZakatTracker instance. + + The dictionary contains two keys: 'database' and 'ram'. Each key maps to a tuple containing two elements: + - The initial size of the respective statistic in bytes (int). + - The initial size of the respective statistic in a human-readable format (str). + + Returns: + dict[str, tuple]: A dictionary with initial statistics for the ZakatTracker instance. + """ + return { + 'database': (0, '0'), + 'ram': (0, '0'), + } + + def stats(self, ignore_ram: bool = True) -> dict[str, tuple[int, str]]: """ Calculates and returns statistics about the object's data storage. @@ -572,6 +588,9 @@ def stats(self) -> dict[str, tuple]: Both sizes are reported in bytes and in a human-readable format (e.g., KB, MB). + Parameters: + ignore_ram (bool): Whether to ignore the RAM size. Default is True + Returns: dict[str, tuple]: A dictionary containing the following statistics: @@ -589,7 +608,7 @@ def stats(self) -> dict[str, tuple]: >>> print(stats['ram']) (12345, '12.1 KB') """ - ram_size = self.get_dict_size(self.vault()) + ram_size = 0.0 if ignore_ram else self.get_dict_size(self.vault()) file_size = os.path.getsize(self.path()) return { 'database': (file_size, self.human_readable_size(file_size)),