diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-07-29 12:21:36 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-07-29 12:21:36 -0700 |
commit | 0b2e1fe70ff23fdbc532017d0b1d89eb3c542b2f (patch) | |
tree | 71d1ae333ebc403372bdec19a3e8a0c18263ea35 /tools | |
parent | 3813179e83e48a82f55d369bc9014bfb64ef6d00 (diff) |
makespec.py: Use check_output for simpler pipe_through_prog
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/makespec.py | 16 |
1 files changed, 7 insertions, 9 deletions
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 = '<div id="TOC">\n\n' + '\n'.join(toclines) + '\n\n</div>\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'␣', '<span class="space"> </span>', result) result = re.sub(r'<h([1-6])><a id="([^\"]*)"><\/a> ', "<h\\1 id=\"\\2\">", 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) |