Skip to content

Commit

Permalink
- إضافة هيكلة بيانات لاحصائيات مساحة الملف والذاكرة المستخدمة لقاعدة …
Browse files Browse the repository at this point in the history
…البيانات.

- إضافة خيار لإمكانية تجاهل حساب الذاكرة العشوائية لقاعدة البيانات.
  • Loading branch information
vzool committed Aug 9, 2024
1 parent c462d27 commit 8928816
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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' },
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
25 changes: 22 additions & 3 deletions zakat/zakat_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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)),
Expand Down

0 comments on commit 8928816

Please sign in to comment.