Print full ocrmypdf output on failure; sanitize control characters in warnings.log
This commit is contained in:
+1
-1
@@ -30,7 +30,7 @@ def write_warnings(book_dir, stage, entries):
|
||||
if os.path.exists(path):
|
||||
with open(path, encoding="utf-8") as f:
|
||||
keep = [ln for ln in f.read().splitlines() if ln and not ln.startswith(stage + " |")]
|
||||
one = lambda t: " / ".join(str(t).split("\n")).strip() # one entry = one line
|
||||
one = lambda t: " / ".join(re.sub(r"[\x00-\x08\x0b-\x1f]", " ", str(t).replace("\r", "\n")).split("\n")).strip() # one entry = one line
|
||||
lines = keep + ["%s | %s | %s | %s" % (stage, k, one(w), one(m)) for k, w, m in entries]
|
||||
with open(path, "w", encoding="utf-8") as f:
|
||||
f.write("\n".join(lines) + ("\n" if lines else ""))
|
||||
|
||||
Reference in New Issue
Block a user