util fixes

This commit is contained in:
Manuel Ebert 2014-09-30 10:16:50 -07:00
parent bd6edffc81
commit c8e5d1ff34

View file

@ -71,15 +71,18 @@ def py2encode(s):
def prompt(msg): def prompt(msg):
"""Prints a message to the std err stream defined in util.""" """Prints a message to the std err stream defined in util."""
if not msg:
return
if not msg.endswith("\n"): if not msg.endswith("\n"):
msg += "\n" msg += "\n"
STDERR.write(u(msg)) STDERR.write(u(msg))
def py23_input(msg=""): def py23_input(msg=""):
STDERR.write(u(msg)) prompt(msg)
return STDIN.readline().strip() return STDIN.readline().strip()
def py23_read(msg=""): def py23_read(msg=""):
prompt(msg)
return STDIN.read() return STDIN.read()
def yesno(prompt, default=True): def yesno(prompt, default=True):
@ -93,7 +96,7 @@ def load_and_fix_json(json_path):
""" """
with open(json_path) as f: with open(json_path) as f:
json_str = f.read() json_str = f.read()
config = fixed = None config = None
try: try:
return json.loads(json_str) return json.loads(json_str)
except ValueError as e: except ValueError as e: