Bruce Eckel added the comment:

Sorry, I thought maybe the error message would be indicative of something. 
Here's the re:

find_output = re.compile(r"/\* (Output:.*)\*/", re.DOTALL)

Here's the program:

#! py -3
# Requires Python 3.5
# Updates generated output into extracted Java programs in "On Java 8"
from pathlib import Path
import re
import pprint
import sys

if __name__ == '__main__':
    find_output = re.compile(r"/\* (Output:.*)\*/", re.DOTALL)
    for outfile in Path(".").rglob("*.p1"):
        print(str(outfile))
        javafile = outfile.with_suffix(".java")
        if not javafile.exists():
            print(str(outfile) + " has no javafile")
            sys.exit(1)
        javatext = javafile.read_text()
        if "/* Output:" not in javatext:
            print(str(javafile) + " has no /* Output:")
            sys.exit(1)
        new_output = outfile.read_text()
        new_javatext = find_output.sub(new_output, javatext)
        javafile.write_text(new_javatext)

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27586>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to