diff options
author | Bnyro <bnyro@tutanota.com> | 2024-07-20 21:27:12 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarIT.de> | 2024-07-27 11:49:58 +0200 |
commit | 304ddd8114e12f4fdd5057dc933a2981bd9e1ec7 (patch) | |
tree | 036c00c01e08e1dd1eb1a6ee136f88d8d5871848 /searx/utils.py | |
parent | 3f22dbb68ab1b1effa84048e15651c5b2e6aa160 (diff) | |
download | searxng-304ddd8114e12f4fdd5057dc933a2981bd9e1ec7.tar.gz searxng-304ddd8114e12f4fdd5057dc933a2981bd9e1ec7.zip |
[feat] videos template: support for view count
Diffstat (limited to 'searx/utils.py')
-rw-r--r-- | searx/utils.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/searx/utils.py b/searx/utils.py index 191161bde..407d44cd0 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -334,6 +334,18 @@ def humanize_bytes(size, precision=2): return "%.*f %s" % (precision, size, s[p]) +def humanize_number(size, precision=0): + """Determine the *human readable* value of a decimal number.""" + s = ['', 'K', 'M', 'B', 'T'] + + x = len(s) + p = 0 + while size > 1000 and p < x: + p += 1 + size = size / 1000.0 + return "%.*f%s" % (precision, size, s[p]) + + def convert_str_to_int(number_str: str) -> int: """Convert number_str to int or 0 if number_str is not a number.""" if number_str.isdigit(): |