Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
JobFactory.__init__(self, "ExportPreviewer")
self.__main_win = main_win
def make(self, exporter):
job = JobExportPreviewer(self, next(self.id_generator), exporter)
job.connect('export-preview-start',
lambda job:
GObject.idle_add(self.__main_win.on_export_preview_start))
job.connect('export-preview-done',
lambda job, size, pixbuf:
GObject.idle_add(self.__main_win.on_export_preview_done,
size, pixbuf))
return job
class JobPageEditor(Job):
__gsignals__ = {
'page-editing-img-edit': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_PYOBJECT, )),
'page-editing-ocr': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_PYOBJECT, )),
'page-editing-index-upd': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_PYOBJECT, )),
'page-editing-done': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_PYOBJECT, )),
}
can_stop = False
priority = 10
def __init__(self, factory, id, docsearch, langs, page, changes=[]):
Job.__init__(self, factory, id)
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))
job.connect(
'doc-examination-end',
lambda job: GObject.idle_add(
self.__main_win.on_doc_examination_end_cb, job))
return job
class JobIndexUpdater(Job):
"""
Update the index
"""
__gsignals__ = {
'index-update-start': (GObject.SignalFlags.RUN_LAST, None, ()),
'index-update-progression': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_FLOAT,
GObject.TYPE_STRING)),
'index-update-interrupted': (GObject.SignalFlags.RUN_LAST, None, ()),
'index-update-end': (GObject.SignalFlags.RUN_LAST, None, ()),
}
can_stop = True
priority = 15
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:
GObject.idle_add(self.__main_win.on_page_thumbnailing_end_cb,
thumbnailer))
return job
class JobDocThumbnailer(Job):
"""
Generate doc list thumbnails
"""
THUMB_WIDTH = 150
THUMB_HEIGHT = 220
__gsignals__ = {
'doc-thumbnailing-start': (GObject.SignalFlags.RUN_LAST, None, ()),
'doc-thumbnailing-doc-done': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_INT,
GObject.TYPE_PYOBJECT)),
'doc-thumbnailing-end': (GObject.SignalFlags.RUN_LAST, None, ()),
}
can_stop = True
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:
GObject.idle_add(self.__main_win.on_img_building_result_stock, img))
job.connect('img-building-result-clear',
lambda builder:
GObject.idle_add(self.__main_win.on_img_building_result_clear))
return job
class JobLabelUpdater(Job):
__gsignals__ = {
'label-updating-start': (GObject.SignalFlags.RUN_LAST, None, ()),
'label-updating-doc-updated': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_FLOAT,
GObject.TYPE_STRING)),
'label-updating-end': (GObject.SignalFlags.RUN_LAST, None, ()),
}
can_stop = False
priority = 5
def __init__(self, factory, id, docsearch, old_label, new_label):
Job.__init__(self, factory, id)
self.__docsearch = docsearch
self.__old_label = old_label
self.__new_label = new_label
os.mkdir(config.workdir, 0750)
def check_scanner(main_win, config):
if config.scanner_devid is not None:
return True
main_win.actions['open_settings'][1].do()
return False
def sort_documents_by_date(documents):
documents.sort()
documents.reverse()
class JobIndexLoader(Job):
"""
Reload the doc index
"""
__gsignals__ = {
'index-loading-start': (GObject.SignalFlags.RUN_LAST, None, ()),
'index-loading-progression': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_FLOAT,
GObject.TYPE_STRING)),
'index-loading-end': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_PYOBJECT, )),
}
can_stop = True
priority = 100
job))
job.connect('single-scan-done',
lambda job, page:
GObject.idle_add(self.__main_win.on_single_scan_done,
job, page))
job.connect('single-scan-no-scanner-found',
lambda job:
GObject.idle_add(popup_no_scanner_found, self.__main_win))
job.connect('single-scan-error',
lambda job, error:
GObject.idle_add(self.__main_win.on_single_scan_error,
job, error))
return job
class JobImporter(Job):
__gsignals__ = {
'import-start': (GObject.SignalFlags.RUN_LAST, None, ()),
'import-done': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_PYOBJECT, # Doc
GObject.TYPE_PYOBJECT),), # Page
}
can_stop = False
priority = 10
def __init__(self, factory, id,
config, docsearch, doc,
importer, file_uri):
Job.__init__(self, factory, id)
self.__config = config
self.__docsearch = docsearch
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,
ocr_redoer, progression, doc_name))
job.connect('redo-ocr-end',
lambda ocr_redoer:
GObject.idle_add(self.__main_win.on_redo_ocr_end_cb,
ocr_redoer))
return job
class JobSingleScan(Job):
__gsignals__ = {
'single-scan-start': (GObject.SignalFlags.RUN_LAST, None, ()),
'single-scan-ocr': (GObject.SignalFlags.RUN_LAST, None, ()),
'single-scan-done': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_PYOBJECT,)), # ImgPage
'single-scan-no-scanner-found': (GObject.SignalFlags.RUN_LAST, None,
()),
'single-scan-error': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)),
}
can_stop = False
priority = 5
def __init__(self, factory, id, config, docsearch, target_doc):
Job.__init__(self, factory, id)
self.__main_win.on_label_updating_start_cb,
updater))
job.connect('label-updating-doc-updated',
lambda updater, progression, doc_name:
GObject.idle_add(
self.__main_win.on_label_updating_doc_updated_cb,
updater, progression, doc_name))
job.connect('label-updating-end',
lambda updater:
GObject.idle_add(
self.__main_win.on_label_updating_end_cb,
updater))
return job
class JobLabelDeleter(Job):
__gsignals__ = {
'label-deletion-start': (GObject.SignalFlags.RUN_LAST, None, ()),
'label-deletion-doc-updated': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_FLOAT,
GObject.TYPE_STRING)),
'label-deletion-end': (GObject.SignalFlags.RUN_LAST, None, ()),
}
can_stop = False
priority = 5
def __init__(self, factory, id, docsearch, label):
Job.__init__(self, factory, id)
self.__docsearch = docsearch
self.__label = label
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(
self.__main_window.on_index_loading_end_cb, loader,
docsearch))
return job
class JobDocExaminer(Job):
"""
Look for modified documents
"""
__gsignals__ = {
'doc-examination-start': (GObject.SignalFlags.RUN_LAST, None, ()),
'doc-examination-progression': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_FLOAT,
GObject.TYPE_STRING)),
'doc-examination-end': (GObject.SignalFlags.RUN_LAST, None, ()),
}
can_stop = True
priority = 50
def __init__(self, factory, id, config, docsearch):