James R. Barlow and aider
7b37f57b1c
refactor: replace Namespace with OCROptions in plugins and validation
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-21 12:21:46 -08:00
James R. Barlow and aider
4476e81240
refactor: remove redundant validation functions from _validation.py
...
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-13 11:42:23 -08:00
James R. Barlow
d556014185
Remove language warning
2025-12-13 11:41:58 -08:00
James R. Barlow and aider
1579337ebe
refactor: Create OCROptions model with Namespace compatibility
...
This commit introduces a new `OCROptions` class in `_options.py` that provides:
- Proper typing for OCRmyPDF options
- Pydantic validation
- Backward compatibility with `argparse.Namespace`
- Gradual migration support for the options system
Key changes:
- Added comprehensive option fields with type hints
- Implemented custom attribute access methods
- Created conversion methods between Namespace and OCROptions
- Updated type hints in multiple files to support both types
- Maintained existing validation logic
The new model allows for a step-by-step refactoring of the options handling throughout the project.
Co-authored-by: aider (openrouter/anthropic/claude-sonnet-4) <aider@aider.chat >
2025-12-13 11:40:57 -08:00
James R. Barlow
18b59c57b4
Refactor our tests that check if we are in a container
2024-10-27 11:55:22 -07:00
James R. Barlow
59f6bc8306
More Tesseract-specific language checks to its plugin
2024-06-01 00:15:50 -07:00
James R. Barlow
d947ca258e
Prevent issuing equ and osd as languages
2024-05-25 01:17:57 -07:00
James R. Barlow
26432c38a9
Raise exception if rotate pages threshold adjusted without --rotate-pages
...
Fixes Make usage of --rotate-pages-threshold clearer #1309
2024-05-18 23:49:27 -07:00
James R. Barlow
94615f7ad4
hOCR now works for all languages
2023-11-19 23:51:27 -08:00
James R. Barlow
95b14ee282
Refactor lossless reconstruction setter into separate function
...
Still messy but good enough as a start.
2023-10-24 00:52:31 -07:00
James R. Barlow
5285d68fcc
Add check for filenotfound due to being inside a snap
2023-10-11 01:02:50 -07:00
James R. Barlow
113a6b45bd
ruff autofixes (mostly typing.* -> collections.abc.*)
2023-10-01 00:02:53 -07:00
James R. Barlow
c8e6f20f8d
Change 32-bit message from error to warning
2023-09-26 20:03:06 -07:00
James R. Barlow
3e1b3ec98d
Merge branch 'feature/fix-raster-dpi-too-high' into v15
2023-09-21 00:05:56 -07:00
James R. Barlow
2637e84691
Complain about all 32-bit interpreters, not just windows
2023-09-21 00:05:39 -07:00
James R. Barlow
b2cbbf0099
Migrate --pdfa-image-compression argument to being managed by Ghostscript plugin
2023-09-20 15:20:42 -07:00
James R. Barlow
5124daa79f
Fix test failures from preceding
2023-06-19 23:25:31 -07:00
Abe
59fd0ac587
Fix randomly ordered languages from set()
2023-06-16 22:14:40 +02:00
James R. Barlow
7af5dcd4a4
Improve directions about install other languages
2023-05-05 13:35:27 -07:00
James R. Barlow
b7eb93eb79
Adopt ruff and fix prelim lints
2023-04-14 00:19:17 -07:00
James R. Barlow
8a8c06c79c
Update pre-commit for py3.8+
2022-08-02 15:05:43 -07:00
James R. Barlow
ba372e5841
Reorganize validation to fix exception when Tesseract not installed
...
The existing logic would call an OCR plugin's get_languages function before
allowing the plugin to check if its dependencies were available. This caused
an exception if Tesseract was installed, when we were supposed to issue
an error message advising the user to install Tesseract.
2022-08-01 02:04:09 -07:00
James R. Barlow
80ed2117cc
Change to SPDX license tracking
2022-07-28 01:10:07 -07:00
James R. Barlow
dc6f1a266a
Modernize type annotations
2022-07-23 00:39:24 -07:00
James R. Barlow
17a5b8b43c
Refactor reporting of optimization failures
2022-06-13 01:30:15 -07:00
James R. Barlow
61069660a2
Move optimization options to plugin
2022-06-12 02:42:16 -07:00
James R. Barlow
b17fb61389
Configure pylint in pyproject and delint
2022-06-12 00:30:44 -07:00
James Barlow
776ada6713
Upgrade pre-commit and associated tools; various lints
2022-04-03 20:53:01 -07:00
James R. Barlow
6910c48b81
Fix test_outputtype_none on Windows and cleanup docs
2021-12-06 15:38:38 -08:00
James R. Barlow
698e8791d7
Remove Python 3.6 specific unicode environment checks
2021-11-13 00:28:52 -08:00
James R. Barlow
380b981763
Remove most Python 3.6 special casing
2021-11-13 00:27:48 -08:00
James R. Barlow
1c4d5d79f7
Improve some error messages
2021-10-28 01:16:22 -07:00
James R. Barlow
790d3022f6
Implement --output-type=none to skip producing the PDF and use only the sidecar
...
Closes #787
2021-09-26 01:07:34 -07:00
James R. Barlow
c725bf79da
flake8 delinting
2021-09-21 16:37:03 -07:00
James R. Barlow
72279e7759
typing: confirmed that _pages_from_ranges(not-str) is never used
2021-08-26 23:47:11 -07:00
James R. Barlow
6f9b948064
typing: fix some trivial issues
2021-08-26 23:46:44 -07:00
James R. Barlow
4eca0a165b
pre-commit: pyupgrade modernizing
2021-08-26 18:04:38 -07:00
James R. Barlow
0b834411fe
validation: mention ISO 639-2 to give people a clue about how to find the appropriate code
2021-06-28 15:19:59 -07:00
James R. Barlow
a964080f77
validation: a word
2021-05-27 13:42:05 -07:00
James R. Barlow
f3715daf15
Move HOCR_OK_LANGS to hocrtransform.py
2021-05-23 01:15:53 -07:00
James R. Barlow
c87221a4e6
validation: add proper list of languages supported by hocr
...
Based on Latin-1 support in default PDF fonts.
2021-05-23 01:14:15 -07:00
James R. Barlow
be45871d10
docker: add special hint for using docker
2021-04-21 23:18:29 -07:00
James R. Barlow
079c162a96
Ensure sidecar is not input or output file
2021-03-05 00:29:42 -08:00
James R. Barlow
25c8c4656f
Fix error message change
2021-03-03 01:02:59 -08:00
James R. Barlow
6e71fe1186
Clarify --unpaper-args errors
2021-03-03 00:44:21 -08:00
Dima Kuznetsov and GitHub
5e2206bae7
Allow --sidecar along --pages ( #735 )
2021-02-19 16:55:35 -08:00
James R. Barlow
3675ae918c
Fix certain invalid page ranges causing exception
...
Closes #686
2020-12-22 01:22:14 -08:00
James R. Barlow
68a57a7839
Add feature to generate hocr-pdf with visible debug text
2020-12-04 17:38:48 -08:00
James R. Barlow
d55e673d9c
Fix warning about --pdfa-image-compression argument at wrong times
...
Closes #663
2020-10-27 23:09:45 -07:00
James R. Barlow
306a903854
Remove unused function log_page_orientations
2020-09-17 01:20:02 -07:00