diff --git a/src/ocrmypdf/_validation.py b/src/ocrmypdf/_validation.py index 153ea22a9..cae63f6a3 100644 --- a/src/ocrmypdf/_validation.py +++ b/src/ocrmypdf/_validation.py @@ -53,13 +53,13 @@ def check_platform() -> None: def check_options_languages(options: Namespace, ocr_engine_languages: set[str]) -> None: if not options.languages: - options.languages = {DEFAULT_LANGUAGE} + options.languages = [DEFAULT_LANGUAGE] system_lang = locale.getlocale()[0] if system_lang and not system_lang.startswith('en'): log.debug("No language specified; assuming --language %s", DEFAULT_LANGUAGE) if not ocr_engine_languages: return - missing_languages = options.languages - ocr_engine_languages + missing_languages = set(options.languages) - ocr_engine_languages if missing_languages: lang_text = '\n'.join(lang for lang in missing_languages) msg = ( @@ -79,7 +79,7 @@ def check_options_languages(options: Namespace, ocr_engine_languages: set[str]) def check_options_output(options: Namespace) -> None: - is_latin = options.languages.issubset(HOCR_OK_LANGS) + is_latin = set(options.languages).issubset(HOCR_OK_LANGS) if options.pdf_renderer.startswith('hocr') and not is_latin: log.warning( diff --git a/src/ocrmypdf/cli.py b/src/ocrmypdf/cli.py index 5d73b22c4..3481b143b 100644 --- a/src/ocrmypdf/cli.py +++ b/src/ocrmypdf/cli.py @@ -84,16 +84,16 @@ class LanguageSetAction(argparse.Action): def __init__(self, option_strings, dest, default=None, **kwargs): """Initialize the action.""" if default is None: - default = set() + default = list() super().__init__(option_strings, dest, default=default, **kwargs) def __call__(self, parser, namespace, values, option_string=None): """Add a language to the set.""" dest = getattr(namespace, self.dest) if '+' in values: - dest.update(lang for lang in values.split('+')) + [dest.append(lang) for lang in values.split('+')] else: - dest.add(values) + dest.append(values) def get_parser():