diff options
author | Bnyro <bnyro@tutanota.com> | 2024-06-12 22:35:13 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-06-15 15:42:29 +0200 |
commit | e9f8412a6e4b399a3335da73b3d321104bb0c4fb (patch) | |
tree | 0caf5c1bede7bb8739c5c2e5d107fa75455ecc24 /searx/utils.py | |
parent | 16ce5612dd0ef426b6851ab97b248595f3933d8f (diff) | |
download | searxng-e9f8412a6e4b399a3335da73b3d321104bb0c4fb.tar.gz searxng-e9f8412a6e4b399a3335da73b3d321104bb0c4fb.zip |
[perf] torrents.html, files.html: don't parse and re-format filesize
Diffstat (limited to 'searx/utils.py')
-rw-r--r-- | searx/utils.py | 23 |
1 files changed, 0 insertions, 23 deletions
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'] |