[issue27586] Is this a regular expression library bug?
Bruce Eckel
report at bugs.python.org
Thu Jul 21 17:09:43 EDT 2016
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 <report at bugs.python.org>
<http://bugs.python.org/issue27586>
_______________________________________
More information about the Python-bugs-list
mailing list