Replace fileinput with regular open-replace

fileinput is supposed to save time in these cases but it's not capable
of doing both in-place rewrites and working with a non-ascii encoding.
This was not noticed until characters outside of ASCII were picked up
by tesseract and saved in a HOCR file. Rework some surrounding code as
well and add multilingual test cases.
This commit is contained in:
James R. Barlow
2015-08-18 23:27:50 -07:00
parent 898b2b000a
commit cc161780df
3 changed files with 4056 additions and 13 deletions
File diff suppressed because one or more lines are too long
+12
View File
@@ -293,3 +293,15 @@ def test_blank_input_pdf():
'blank.pdf', 'still_blank.pdf')
assert p.returncode == ExitCode.ok
def test_french():
p, out, err = run_ocrmypdf_env(
'français.pdf', 'français.pdf', '-l', 'fra')
assert p.returncode == ExitCode.ok, \
"This test may fail if Tesseract language packs are missing"
def test_klingon():
p, out, err = run_ocrmypdf_env(
'français.pdf', 'français.pdf', '-l', 'klz')
assert p.returncode == ExitCode.bad_args