Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
)
@staticmethod
def get_select_mime_types():
return IMG_MIME_TYPES
@staticmethod
def get_mime_types():
return IMG_MIME_TYPES
def __str__(self):
return _("Append the image to the current document")
FS = fs.GioFileSystem()
IMPORTERS = [
PdfDirectoryImporter(FS),
PdfImporter(FS),
ImageDirectoryImporter(FS),
ImageImporter(FS),
]
def get_possible_importers(file_uris, current_doc=None):
"""
Return all the importer objects that can handle the specified files.
Possible imports may vary depending on the currently active document
"""
importers = []
for importer in IMPORTERS:
Paperwork configuration management code
"""
import base64
import configparser
import logging
import os
import pyocr
from . import util
from . import fs
from .util import find_language
logger = logging.getLogger(__name__)
FS = fs.GioFileSystem()
DEFAULT_OCR_LANG = "eng" # if really we can't guess anything
def paperwork_cfg_boolean(string):
if string.lower() == "true":
return True
return False
class PaperworkSetting(object):
def __init__(self, section, token, default_value_func=lambda: None,
constructor=str):
self.section = section
self.token = token
self.default_value_func = default_value_func
import gi
import pyocr
gi.require_version('Gdk', '3.0')
gi.require_version('PangoCairo', '1.0')
gi.require_version('Poppler', '0.18')
from . import config # noqa: E402
from . import docimport # noqa: E402
from . import docsearch # noqa: E402
from .labels import Label # noqa: E402
from . import fs # noqa: E402
FS = fs.GioFileSystem()
def is_verbose():
return os.environ['PAPERWORK_SHELL_VERBOSE'] != ""
def is_interactive():
return os.environ['PAPERWORK_INTERACTIVE'] != ""
def verbose(txt):
if is_verbose():
print(txt)
def reply(data):
def __init__(self, rootdir, indexdir=None, language=None,
use_default_index_client=True):
"""
Index files in rootdir (see constructor)
"""
if use_default_index_client:
self.index = DEFAULT_INDEX_CLIENT
else:
self.index = PaperworkIndexClient()
self.fs = fs.GioFileSystem()
self.rootdir = self.fs.safe(rootdir)
localdir = os.path.expanduser("~/.local")
base_data_dir = os.getenv(
"XDG_DATA_HOME",
os.path.join(localdir, "share")
)
if indexdir is None:
indexdir = os.path.join(base_data_dir, "paperwork")
indexdir = os.path.join(indexdir, "index")
label_guesser_dir = os.path.join(indexdir, "label_guessing")
self.index.open(localdir, base_data_dir, indexdir, label_guesser_dir,
rootdir, language=language)
from .common.export import Exporter
from .common.export import dummy_export_progress_cb
from . import fs
FS = fs.GioFileSystem()
class MultipleDocExporter(Exporter):
can_select_format = False
can_change_quality = False
def __init__(self, doclist):
super().__init__(doclist, 'PDF')
global FS
self.fs = FS
self.doclist = doclist
self.exporters = [doc.build_exporter() for doc in doclist]
self.ref_exporter = self.exporters[0]
self.ref_doc = doclist[0]
self.nb_pages = 0