From 0b2e1fe70ff23fdbc532017d0b1d89eb3c542b2f Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Wed, 29 Jul 2015 12:21:36 -0700 Subject: makespec.py: Use check_output for simpler pipe_through_prog --- tools/makespec.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'tools') diff --git a/tools/makespec.py b/tools/makespec.py index d182105..925f23c 100755 --- a/tools/makespec.py +++ b/tools/makespec.py @@ -37,9 +37,8 @@ def parseYaml(yaml): return metadata def pipe_through_prog(prog, text): - p1 = Popen(prog.split(), stdout=PIPE, stdin=PIPE, stderr=PIPE) - [result, err_out] = p1.communicate(input=text.encode('utf-8')) - return [p1.returncode, result.decode('utf-8'), err_out] + result = check_output(prog.split(), input=text.encode('utf-8')) + return result.decode('utf-8') def replaceAnchor(match): refs.append("[{0}]: #{1}".format(match.group(1), match.group(2))) @@ -138,8 +137,11 @@ elif specformat == "html": section['contents'] + '](#' + section['ident'] + ')') toc = '
\n\n' + '\n'.join(toclines) + '\n\n
\n\n' prog = "cmark --smart" - [retcode, result, err_out] = pipe_through_prog(prog, toc + mdtext) - if retcode == 0: + result = pipe_through_prog(prog, toc + mdtext) + if result == '': + err("Error converting markdown version of spec to HTML.\n") + exit(1) + else: result = re.sub(r'␣', ' ', result) result = re.sub(r'<\/a> ', "", result) @@ -165,9 +167,5 @@ elif specformat == "html": else: reftexts.append(ref) - else: - err("Error converting markdown version of spec:\n") - sys.stderr.buffer.write(err_out) - exit(1) exit(0) -- cgit v1.2.3