From 1519e66550058ade3ee6bbdbf66543523a76ed5e Mon Sep 17 00:00:00 2001 From: jonaswinkler <17569239+jonaswinkler@users.noreply.github.com> Date: Sat, 15 May 2021 15:14:22 +0200 Subject: [PATCH] fix pycodestyle --- test.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 test.py diff --git a/test.py b/test.py new file mode 100644 index 000000000..18a97bacb --- /dev/null +++ b/test.py @@ -0,0 +1,40 @@ +import ocrmypdf +from ocrmypdf import ocr, hookimpl +from ocrmypdf._concurrent import NullProgressBar + + +def get_unified_progress(self, desc, current, total): + steps = ["Scanning contents", "OCR", "PDF/A conversion"] + if desc in steps: + index = steps.index(desc) + return (index / len(steps)) + (current / total) / len(steps) + else: + return 0 + + +class MyProgressBar: + + # __enter__, __exit__ and others removed for simplicity + + def update(self, *args, **kwargs): + pass + # i'd need to call MyOcrClass.progress() here. + + +@hookimpl +def get_progressbar_class(*args, **kwargs): + return MyProgressBar + + +class MyOcrClass: + + def progress(self, current_p, max_p): + # send progress over web sockets, *requires* self reference + pass + + def run(self): + ocrmypdf.ocr("test.pdf", "test_out.pdf", skip_text=True, jobs=1, plugins="test") + + +if __name__ == '__main__': + MyOcrClass().run()