How to use the paperwork-backend.paperwork_backend.img.doc.ImgDoc function in paperwork-backend

To help you get started, we’ve selected a few paperwork-backend 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 / paperwork-backend / paperwork_backend / index.py View on Github external
logger = logging.getLogger(__name__)


COMMAND = collections.namedtuple(
    "COMMAND", ["func", "args", "kwargs"]
)
RESULT = collections.namedtuple(
    "RESULT", ["exc", "ret"]
)


DOC_TYPE_LIST = [
    (is_pdf_doc, PdfDoc.doctype, PdfDoc),
    (is_img_doc, ImgDoc.doctype, ImgDoc)
]


class PaperworkIndex(object):
    WHOOSH_SCHEMA = whoosh.fields.Schema(
        # static up to date schema
        docid=whoosh.fields.ID(stored=True, unique=True),
        doctype=whoosh.fields.ID(stored=True, unique=False),
        docfilehash=whoosh.fields.ID(stored=True),
        content=whoosh.fields.TEXT(spelling=True, stored=True),
        label=whoosh.fields.KEYWORD(stored=True, commas=True,
                                    scorable=True),
        date=whoosh.fields.DATETIME(stored=True),
        last_read=whoosh.fields.DATETIME(stored=True),
    )
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / docimport.py View on Github external
def import_doc(self, file_uris, docsearch, current_doc=None):
        """
        Import the specified images
        """
        if (current_doc is None or
                current_doc.is_new or
                not current_doc.can_edit):
            if not current_doc or not current_doc.can_edit:
                current_doc = ImgDoc(self.fs, docsearch.rootdir)
            new_docs = [current_doc]
            upd_docs = []
        else:
            new_docs = []
            upd_docs = [current_doc]
        new_docs_pages = []
        upd_docs_pages = []
        page = None

        file_uris = [self.fs.safe(uri) for uri in file_uris]
        for file_uri in file_uris:
            logger.info("Importing image '%s'" % (file_uri))

            with self.fs.open(file_uri, "rb") as fd:
                img = Image.open(fd)
                img.load()
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / docimport.py View on Github external
def __init__(self, fs):
        super().__init__(fs, ImgDoc.IMPORT_IMG_EXTENSIONS)
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / index.py View on Github external
def continue_examine_rootdir2(self):
        old_doc = None
        try:
            old_doc = next(self.examine_rootdir_data['old_doc_list_iter'])
        except StopIteration:
            return ('end', None)

        docpath = self.fs.join(self.rootdir, old_doc)
        return ('deleted', ImgDoc(self.fs, docpath, old_doc))