From e9f8412a6e4b399a3335da73b3d321104bb0c4fb Mon Sep 17 00:00:00 2001 From: Bnyro Date: Wed, 12 Jun 2024 22:35:13 +0200 Subject: [perf] torrents.html, files.html: don't parse and re-format filesize --- searx/utils.py | 23 ----------------------- 1 file changed, 23 deletions(-) (limited to 'searx/utils.py') diff --git a/searx/utils.py b/searx/utils.py index 58ff72bb9..0c11ccc65 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -332,29 +332,6 @@ def dict_subset(dictionary: MutableMapping, properties: Set[str]) -> Dict: return {k: dictionary[k] for k in properties if k in dictionary} -def get_torrent_size(filesize: str, filesize_multiplier: str) -> Optional[int]: - """ - - Args: - * filesize (str): size - * filesize_multiplier (str): TB, GB, .... TiB, GiB... - - Returns: - * int: number of bytes - - Example: - >>> get_torrent_size('5', 'GB') - 5368709120 - >>> get_torrent_size('3.14', 'MiB') - 3140000 - """ - try: - multiplier = _STORAGE_UNIT_VALUE.get(filesize_multiplier, 1) - return int(float(filesize) * multiplier) - except ValueError: - return None - - def humanize_bytes(size, precision=2): """Determine the *human readable* value of bytes on 1024 base (1KB=1024B).""" s = ['B ', 'KB', 'MB', 'GB', 'TB'] -- cgit v1.2.3