mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-12 01:18:31 +02:00
util fixes
This commit is contained in:
parent
bd6edffc81
commit
c8e5d1ff34
1 changed files with 5 additions and 2 deletions
|
@ -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:
|
||||||
|
|
Loading…
Add table
Reference in a new issue