INNER CODE UNIT · Python
parse_ttl
selkies-project/selkies · addons/turn-rest/app.py:58
def parse_ttl(value, fallback: int) -> int:
"""Parse a positive credential TTL in seconds, falling back otherwise."""
try:
ttl = int(value)
if ttl > 0:
return ttl
except (TypeError, ValueError):
pass
return fallback
def parse_bool(value, fallback: bool = False) -> bool:
"""Parse a permissive boolean string; unrecognized values take the fallback."""
if value is None:
return fallback
value = str(value).strip().lower()
if value in ('1', 'true', 'yes', 'on'):
return True