mirror of
https://github.com/ocrmypdf/OCRmyPDF.git
synced 2026-05-24 22:46:07 -04:00
api/cli: replace private variable access with method
This commit is contained in:
@@ -193,7 +193,7 @@ def create_options(
|
||||
else:
|
||||
cmdline.append(os.fspath(output_file))
|
||||
|
||||
parser._api_mode = True
|
||||
parser.enable_api_mode()
|
||||
options = parser.parse_args(cmdline)
|
||||
for keyword, val in deferred:
|
||||
setattr(options, keyword, val)
|
||||
|
||||
@@ -63,6 +63,9 @@ class ArgumentParser(argparse.ArgumentParser):
|
||||
super().__init__(*args, **kwargs)
|
||||
self._api_mode = False
|
||||
|
||||
def enable_api_mode(self):
|
||||
self._api_mode = True
|
||||
|
||||
def error(self, message):
|
||||
if not self._api_mode:
|
||||
super().error(message)
|
||||
|
||||
Reference in New Issue
Block a user