mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-05-01 11:12:24 +02:00

Simplify state sharing by having all dangerzone core logic in one single class instead of two.
38 lines
845 B
Python
38 lines
845 B
Python
import gzip
|
|
import json
|
|
import logging
|
|
import pathlib
|
|
import platform
|
|
import shutil
|
|
import subprocess
|
|
import sys
|
|
from typing import Optional
|
|
|
|
import appdirs
|
|
import colorama
|
|
|
|
from .container import convert
|
|
from .settings import Settings
|
|
from .util import get_resource_path
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
|
|
class DangerzoneCore(object):
|
|
"""
|
|
Singleton of shared state / functionality throughout the app
|
|
"""
|
|
|
|
def __init__(self) -> None:
|
|
# Initialize terminal colors
|
|
colorama.init(autoreset=True)
|
|
|
|
# App data folder
|
|
self.appdata_path = appdirs.user_config_dir("dangerzone")
|
|
|
|
# Languages supported by tesseract
|
|
with open(get_resource_path("ocr-languages.json"), "r") as f:
|
|
self.ocr_languages = json.load(f)
|
|
|
|
# Load settings
|
|
self.settings = Settings(self)
|