Ejemplo n.º 1
0
def extract_update_bundle(bundle):
    past_update_dir = paths.data_path("update")
    if past_update_dir.exists():
        log.info("Found previous update data. Removing...")
        shutil.rmtree(past_update_dir, ignore_errors=True)
    log.debug("Extracting update bundle")
    extraction_dir = paths.data_path("update", "extracted")
    extraction_dir.mkdir(parents=True, exist_ok=True)
    with zipfile.ZipFile(bundle, compression=zipfile.ZIP_LZMA) as archive:
        archive.extractall(extraction_dir)
    return extraction_dir
Ejemplo n.º 2
0
def extract_update_bundle(bundle):
    past_update_dir = paths.data_path("update")
    if past_update_dir.exists():
        log.info("Found previous update data. Removing...")
        shutil.rmtree(past_update_dir, ignore_errors=True)
    log.debug("Extracting update bundle")
    bundle.seek(0)
    extraction_dir = paths.data_path("update", "extracted")
    if extraction_dir.exists():
        shutil.rmtree(extraction_dir)
    extraction_dir.mkdir(parents=True, exist_ok=True)
    archive_file = BytesIO(decompress(bundle.read()))
    with zipfile.ZipFile(archive_file) as archive:
        archive.extractall(extraction_dir)
    return extraction_dir
Ejemplo n.º 3
0
def get_bundled_documents_folder():
    bd_path = paths.data_path("bundled_documents")
    if not bd_path.exists():
        bd_path.mkdir(parents=True, exist_ok=True)
    return bd_path
Ejemplo n.º 4
0
def get_tesseract_path():
    return data_path(f"tesseract_ocr_{app.arch}").resolve()
Ejemplo n.º 5
0
 def get_xpdf_config_file():
     xpdf_config = data_path("xpdf_config", "default.xpdf")
     if not xpdf_config.exists():
         xpdf_config.parent.mkdir(parents=True, exist_ok=True)
         xpdf_config.write_text(generate_xpdfrc())
     return xpdf_config