MCPcopy Create free account
hub / github.com/celery/celery / strtobool

Function strtobool

celery/utils/serialization.py:200–212  ·  view source on GitHub ↗

Convert common terms for true/false to bool. Examples (true/false/yes/no/on/off/1/0).

(term, table=None)

Source from the content-addressed store, hash-verified

198
199
200def 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
215def _datetime_to_json(dt):

Callers 5

test_default_tableMethod · 0.90
test_unknown_valueMethod · 0.90
test_no_opMethod · 0.90
test_custom_tableMethod · 0.90
default.pyFile · 0.90

Calls

no outgoing calls

Tested by 4

test_default_tableMethod · 0.72
test_unknown_valueMethod · 0.72
test_no_opMethod · 0.72
test_custom_tableMethod · 0.72