microblog.pub/utils/__init__.py

13 lines
271 B
Python
Raw Normal View History

2018-05-22 17:57:34 -05:00
import logging
logger = logging.getLogger(__name__)
def strtobool(s: str) -> bool:
if s in ['y', 'yes', 'true', 'on', '1']:
return True
if s in ['n', 'no', 'false', 'off', '0']:
return False
raise ValueError(f'cannot convert {s} to bool')