How to use the paperwork-backend.paperwork_backend.config.PaperworkConfig 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 / shell.py View on Github external
"reason": "xxxx", "args": "(xxxx, )"
        }
        --
        {
            "status": "ok",
            "old_workdir": "file:///home/jflesch/papers",
            "new_workdir": "file:///tmp/papers",
        }
    """
    new_workdir = FS.safe(new_workdir)
    if not FS.exists(new_workdir) or not FS.isdir(new_workdir):
        sys.stderr.write("New work directory {} doesn't exists".format(
            new_workdir
        ))
        return
    pconfig = config.PaperworkConfig()
    pconfig.read()
    r = {
        'old_workdir': pconfig.settings['workdir'].value,
        'new_workdir': new_workdir
    }
    pconfig.settings['workdir'].value = new_workdir
    pconfig.write()
    reply(r)
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / shell.py View on Github external
def get_docsearch():
    pconfig = config.PaperworkConfig()
    pconfig.read()

    verbose("Work directory: {}".format(pconfig.settings['workdir'].value))

    dsearch = docsearch.DocSearch(pconfig.settings['workdir'].value)
    dsearch.reload_index()
    return dsearch
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / shell.py View on Github external
if len(ocr) <= 0:
        raise Exception("No OCR tool found")
    ocr = ocr[0]

    if "--lang" in args:
        idx = args.index("--lang")
        ocr_lang = args[idx + 1]
        args.pop(idx)
        args.pop(idx)

    if "--empty_only" in args:
        empty_only = True
        args.remove("--empty_only")

    if ocr_lang is None:
        pconfig = config.PaperworkConfig()
        pconfig.read()
        ocr_lang = pconfig.settings['ocr_lang'].value

    dsearch = get_docsearch()
    pages = set()
    docs = set()

    for objid in args:
        obj = dsearch.get(objid)
        if hasattr(obj, 'pages'):
            pages.update(obj.pages)
        else:
            pages.add(obj)

    index_updater = dsearch.get_index_updater(optimize=False)
github openpaperwork / paperwork / paperwork-backend / paperwork_backend / shell.py View on Github external
args.pop(idx)
    if len(args) <= 0:
        sys.stderr.write("Nothing to import.\n")
        return

    dsearch = get_docsearch()

    if docid:
        doc = dsearch.get(docid)
        if doc is None:
            sys.stderr.write("Document {} not found\n".format(docid))
            return

    ocr_lang = None
    if ocr is not None:
        pconfig = config.PaperworkConfig()
        pconfig.read()
        ocr_lang = pconfig.settings['ocr_lang'].value
    return _do_import(args, dsearch, doc, ocr, ocr_lang, guess_labels)