Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion makelove/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import atexit
import os
import re
from distutils.util import strtobool

import appdirs

Expand Down Expand Up @@ -33,6 +32,19 @@ def parse_love_version(version_str):
return parts


def strtobool(value):
"""Convert a string representation of truth to true (1) or false (0).
True values are y, yes, t, true, on and 1; false values are n, no, f, false, off and 0. Raises ValueError if val is anything else.
"""
l = value.lower()
if l in ("y", "yes", "t", "true", "on", "1"):
return 1
elif l in ("n", "no", "f", "false", "off", "0"):
return 0
else:
raise ValueError("invalid truth value %r" % (value,))


def ask_yes_no(question, default=None):
if default == None:
option_str = "[y/n]: "
Expand Down