(dictionary, key, default_value=None)
| 793 | |
| 794 | @staticmethod |
| 795 | def safe_integer(dictionary, key, default_value=None): |
| 796 | try: |
| 797 | # needed to avoid breaking on "100.0" |
| 798 | # https://stackoverflow.com/questions/1094717/convert-a-string-to-integer-with-decimal-in-python#1094721 |
| 799 | return int(float(dictionary[key])) |
| 800 | except Exception: |
| 801 | # catch any exception, not only (KeyError, IndexError, TypeError, ValueError): |
| 802 | return default_value |
| 803 | |
| 804 | @staticmethod |
| 805 | def safe_integer_product(dictionary, key, factor, default_value=None): |
no outgoing calls