Convert common terms for true/false to bool. Examples (true/false/yes/no/on/off/1/0).
(term, table=None)
| 198 | |
| 199 | |
| 200 | def strtobool(term, table=None): |
| 201 | """Convert common terms for true/false to bool. |
| 202 | |
| 203 | Examples (true/false/yes/no/on/off/1/0). |
| 204 | """ |
| 205 | if table is None: |
| 206 | table = STRTOBOOL_DEFAULT_TABLE |
| 207 | if isinstance(term, str): |
| 208 | try: |
| 209 | return table[term.lower()] |
| 210 | except KeyError: |
| 211 | raise TypeError(f'Cannot coerce {term!r} to type bool') |
| 212 | return term |
| 213 | |
| 214 | |
| 215 | def _datetime_to_json(dt): |
no outgoing calls