diff options
author | misnyo <misnyo@misnyo.eu> | 2017-09-04 20:05:04 +0200 |
---|---|---|
committer | misnyo <misnyo@misnyo.eu> | 2017-09-04 20:05:04 +0200 |
commit | 33fd938016def4496876d89d0ccaa53f47705005 (patch) | |
tree | be751691b517a3f43ced554515f9131becfdb187 /searx/utils.py | |
parent | c3232b0e1a82315e5936fb3c0731548efd66a0b3 (diff) | |
download | searxng-33fd938016def4496876d89d0ccaa53f47705005.tar.gz searxng-33fd938016def4496876d89d0ccaa53f47705005.zip |
[mod] int_or_zero refactored to searx_utils
Diffstat (limited to 'searx/utils.py')
-rw-r--r-- | searx/utils.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/searx/utils.py b/searx/utils.py index 3df571160..35b20ad83 100644 --- a/searx/utils.py +++ b/searx/utils.py @@ -290,6 +290,15 @@ def convert_str_to_int(number_str): return 0 +# convert a variable to integer or return 0 if it's not a number +def int_or_zero(num): + if isinstance(num, list): + if len(num) < 1: + return 0 + num = num[0] + return convert_str_to_int(num) + + def is_valid_lang(lang): is_abbr = (len(lang) == 2) if is_abbr: |