Enable ruff PTH (flake8-use-pathlib) and fix all findings
Replaces os.path/open()/os.stat()/os.chmod() calls with their Path method equivalents across src, tests, misc, and bin, wrapping str variables in Path(...) where they must stay str for other uses (e.g. subprocess argv, CLI-arg formatting). helpers.safe_symlink() now decodes StrOrBytesPath to a str Path via os.fsdecode() upfront, same pattern already used elsewhere for the str|bytes union.
This commit is contained in:
@@ -74,11 +74,11 @@ class FixedRotateNoopOcrEngine(OcrEngine):
|
||||
def generate_hocr(input_file, output_hocr, output_text, options):
|
||||
with (
|
||||
Image.open(input_file) as im,
|
||||
open(output_hocr, 'w', encoding='utf-8') as f,
|
||||
output_hocr.open('w', encoding='utf-8') as f,
|
||||
):
|
||||
w, h = im.size
|
||||
f.write(HOCR_TEMPLATE.format(str(w), str(h)))
|
||||
with open(output_text, 'w') as f:
|
||||
with output_text.open('w') as f:
|
||||
f.write('')
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -72,11 +72,11 @@ class NoopOcrEngine(OcrEngine):
|
||||
def generate_hocr(input_file, output_hocr, output_text, options):
|
||||
with (
|
||||
Image.open(input_file) as im,
|
||||
open(output_hocr, 'w', encoding='utf-8') as f,
|
||||
output_hocr.open('w', encoding='utf-8') as f,
|
||||
):
|
||||
w, h = im.size
|
||||
f.write(HOCR_TEMPLATE.format(str(w), str(h)))
|
||||
with open(output_text, 'w') as f:
|
||||
with output_text.open('w') as f:
|
||||
f.write('')
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user