How to use the paperwork.frontend.jobs.JobFactory function in paperwork

To help you get started, we’ve selected a few paperwork examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
self.__current_idx = page_idx
            if not self.can_run:
                return
        self.emit('page-thumbnailing-end')

    def stop(self, will_resume=False):
        self.can_run = False
        self._stop_wait()
        if not will_resume and self.__current_idx >= 0:
            self.emit('page-thumbnailing-end')


GObject.type_register(JobPageThumbnailer)


class JobFactoryPageThumbnailer(JobFactory):
    def __init__(self, main_win):
        JobFactory.__init__(self, "PageThumbnailer")
        self.__main_win = main_win

    def make(self, doc, search):
        job = JobPageThumbnailer(self, next(self.id_generator), doc, search)
        job.connect('page-thumbnailing-start',
                    lambda thumbnailer:
                    GObject.idle_add(self.__main_win.on_page_thumbnailing_start_cb,
                                     thumbnailer))
        job.connect('page-thumbnailing-page-done',
                    lambda thumbnailer, page_idx, thumbnail:
                    GObject.idle_add(self.__main_win.on_page_thumbnailing_page_done_cb,
                                     thumbnailer, page_idx, thumbnail))
        job.connect('page-thumbnailing-end',
                    lambda thumbnailer:
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
self.emit('page-editing-ocr', self.__page)
            self.__page.redo_ocr(self.__langs)

            self.emit('page-editing-index-upd', self.__page)
            index_upd = self.__docsearch.get_index_updater(optimize=False)
            index_upd.upd_doc(self.__page.doc)
            index_upd.commit()
        finally:
            self.emit('page-editing-done', self.__page)


GObject.type_register(JobPageEditor)


class JobFactoryPageEditor(JobFactory):
    def __init__(self, main_win, config):
        JobFactory.__init__(self, "PageEditor")
        self.__main_win = main_win
        self.__config = config

    def make(self, docsearch, page, changes):
        job = JobPageEditor(self, next(self.id_generator), docsearch,
                            self.__config.langs, page, changes)
        job.connect('page-editing-img-edit',
                    lambda job, page:
                    GObject.idle_add(
                        self.__main_win.on_page_editing_img_edit_start_cb,
                        job, page))
        job.connect('page-editing-ocr',
                    lambda job, page:
                    GObject.idle_add(self.__main_win.on_page_editing_ocr_cb,
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
% (step, progression, total, doc.name))
        self.emit('redo-ocr-doc-updated', float(progression) / (total + 1),
                  doc.name)

    def do(self):
        self.emit('redo-ocr-start')
        try:
            self.__target.redo_ocr(self.__langs, self.__progress_cb)
        finally:
            self.emit('redo-ocr-end')


GObject.type_register(JobOCRRedoer)


class JobFactoryOCRRedoer(JobFactory):
    def __init__(self, main_win, config):
        JobFactory.__init__(self, "OCRRedoer")
        self.__main_win = main_win
        self.__config = config

    def make(self, target):
        job = JobOCRRedoer(self, next(self.id_generator), self.__config.langs,
                           target)
        job.connect('redo-ocr-start',
                    lambda ocr_redoer:
                    GObject.idle_add(self.__main_win.on_redo_ocr_start_cb,
                                     ocr_redoer))
        job.connect('redo-ocr-doc-updated',
                    lambda ocr_redoer, progression, doc_name:
                    GObject.idle_add(
                        self.__main_win.on_redo_ocr_doc_updated_cb,
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
try:
            docsearch = DocSearch(self.__config.workdir, self.__progress_cb)
            self.emit('index-loading-end', docsearch)
        except StopIteration:
            logger.info("Index loading interrupted")

    def stop(self, will_resume=False):
        self.can_run = False
        if not will_resume:
            self.emit('index-loading-end', None)


GObject.type_register(JobIndexLoader)


class JobFactoryIndexLoader(JobFactory):
    def __init__(self, main_window, config):
        JobFactory.__init__(self, "IndexLoader")
        self.__main_window = main_window
        self.__config = config

    def make(self):
        job = JobIndexLoader(self, next(self.id_generator), self.__config)
        job.connect('index-loading-start',
                    lambda job: GObject.idle_add(
                        self.__main_window.on_index_loading_start_cb, job))
        job.connect('index-loading-progression',
                    lambda job, progression, txt:
                    GObject.idle_add(self.__main_window.set_progression,
                                     job, progression, txt))
        job.connect('index-loading-end',
                    lambda loader, docsearch: GObject.idle_add(
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
self.__doc.scan_single_page(scan_src, scanner.options['resolution'].value,
                                        self.__config.scanner_calibration,
                                        self.__config.langs,
                                        self.__scan_progress_cb)
            page = self.__doc.pages[self.__doc.nb_pages - 1]
            self.__docsearch.index_page(page)
            self.emit('single-scan-done', page)
        except Exception, exc:
            self.emit('single-scan-error', str(exc))
            raise


GObject.type_register(JobSingleScan)


class JobFactorySingleScan(JobFactory):
    def __init__(self, main_win, config):
        JobFactory.__init__(self, "SingleScan")
        self.__main_win = main_win
        self.__config = config

    def make(self, docsearch, target_doc):
        job = JobSingleScan(self, next(self.id_generator), self.__config,
                            docsearch, target_doc)
        job.connect('single-scan-start',
                    lambda job:
                    GObject.idle_add(self.__main_win.on_single_scan_start,
                                     job))
        job.connect('single-scan-ocr',
                    lambda job:
                    GObject.idle_add(self.__main_win.on_single_scan_ocr,
                                     job))
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
except Exception:
            self.emit('img-building-result-stock', Gtk.STOCK_DIALOG_ERROR)
            raise

    def stop(self, will_resume=False):
        self.can_run = False
        self._stop_wait()
        if not will_resume:
            self.emit('img-building-result-clear')
            return


GObject.type_register(JobImgBuilder)


class JobFactoryImgBuilder(JobFactory):
    def __init__(self, main_win):
        JobFactory.__init__(self, "ImgBuilder")
        self.__main_win = main_win

    def make(self, page):
        job = JobImgBuilder(self, next(self.id_generator), page,
                            self.__main_win.get_zoom_factor)
        job.connect('img-building-start',
                    lambda builder:
                    GObject.idle_add(self.__main_win.on_img_building_start))
        job.connect('img-building-result-pixbuf',
                    lambda builder, factor, original_width, img, boxes:
                    GObject.idle_add(self.__main_win.on_img_building_result_pixbuf,
                                     builder, factor, original_width, img, boxes))
        job.connect('img-building-result-stock',
                    lambda builder, img:
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
def __progress_cb(self, progression, total, step, doc):
        self.emit('label-deletion-doc-updated', float(progression) / total,
                  doc.name)

    def do(self):
        self.emit('label-deletion-start')
        try:
            self.__docsearch.destroy_label(self.__label, self.__progress_cb)
        finally:
            self.emit('label-deletion-end')


GObject.type_register(JobLabelDeleter)


class JobFactoryLabelDeleter(JobFactory):
    def __init__(self, main_win):
        JobFactory.__init__(self, "LabelDeleter")
        self.__main_win = main_win

    def make(self, docsearch, label):
        job = JobLabelDeleter(self, next(self.id_generator), docsearch, label)
        job.connect('label-deletion-start',
                    lambda deleter:
                    GObject.idle_add(self.__main_win.on_label_updating_start_cb,
                                     deleter))
        job.connect('label-deletion-doc-updated',
                    lambda deleter, progression, doc_name:
                    GObject.idle_add(
                        self.__main_win.on_label_deletion_doc_updated_cb,
                        deleter, progression, doc_name))
        job.connect('label-deletion-end',
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
_("Writing index ..."))
        self.index_updater.commit()
        self.emit('index-update-progression', 1.0, "")
        self.emit('index-update-end')

    def stop(self, will_resume=False):
        self.can_run = False
        if not will_resume:
            self.connect('index-update-interrupted',
                         lambda job: self.index_updater.cancel())


GObject.type_register(JobIndexUpdater)


class JobFactoryIndexUpdater(JobFactory):
    def __init__(self, main_win, config):
        JobFactory.__init__(self, "IndexUpdater")
        self.__main_win = main_win
        self.__config = config

    def make(self, docsearch,
            new_docs, upd_docs, del_docs, optimize=True):
        job = JobIndexUpdater(self, next(self.id_generator), self.__config,
                              docsearch, new_docs, upd_docs, del_docs, optimize)
        job.connect('index-update-start',
                    lambda updater:
                    GObject.idle_add(self.__main_win.on_index_update_start_cb,
                                     updater))
        job.connect('index-update-progression',
                    lambda updater, progression, txt:
                    GObject.idle_add(self.__main_win.set_progression, updater,
github openpaperwork / paperwork / src / paperwork / frontend / mainwindow.py View on Github external
self.can_run = False

    def __on_new_doc(self, doc):
        self.new_docs.add(doc)

    def __on_doc_changed(self, doc):
        self.docs_changed.add(doc)

    def __on_doc_missing(self, docid):
        self.docs_missing.add(docid)


GObject.type_register(JobDocExaminer)


class JobFactoryDocExaminer(JobFactory):
    def __init__(self, main_win, config):
        JobFactory.__init__(self, "DocExaminer")
        self.__main_win = main_win
        self.__config = config

    def make(self, docsearch):
        job = JobDocExaminer(self, next(self.id_generator),
                             self.__config, docsearch)
        job.connect(
            'doc-examination-start',
            lambda job: GObject.idle_add(
                self.__main_win.on_doc_examination_start_cb, job))
        job.connect(
            'doc-examination-progression',
            lambda job, progression, txt: GObject.idle_add(
                self.__main_win.set_progression, job, progression, txt))