Move top import of setting
This commit is contained in:
@@ -6,7 +6,6 @@ import logging
|
||||
|
||||
from django.utils.encoding import smart_str
|
||||
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
from common.textparser import TextParser, TEXT_PARSER_MIMETYPES
|
||||
from mimetype.api import get_mimetype
|
||||
|
||||
@@ -34,6 +33,8 @@ def cache_cleanup(input_filepath, *args, **kwargs):
|
||||
|
||||
|
||||
def create_image_cache_filename(input_filepath, *args, **kwargs):
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
if input_filepath:
|
||||
hash_value = HASH_FUNCTION(u''.join([HASH_FUNCTION(smart_str(input_filepath)), unicode(args), unicode(kwargs)]))
|
||||
return os.path.join(TEMPORARY_DIRECTORY, hash_value)
|
||||
@@ -43,6 +44,7 @@ def create_image_cache_filename(input_filepath, *args, **kwargs):
|
||||
|
||||
def convert(input_filepath, output_filepath=None, cleanup_files=False, mimetype=None, *args, **kwargs):
|
||||
from .runtime import backend
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
size = kwargs.get('size')
|
||||
file_format = kwargs.get('file_format', DEFAULT_FILE_FORMAT)
|
||||
|
||||
@@ -5,7 +5,6 @@ import subprocess
|
||||
import logging
|
||||
|
||||
from mimetype.api import get_mimetype
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
from .exceptions import OfficeBackendError, UnknownFileFormat
|
||||
|
||||
@@ -45,6 +44,8 @@ class OfficeConverter(object):
|
||||
return CONVERTER_OFFICE_FILE_MIMETYPES
|
||||
|
||||
def convert(self, input_filepath, mimetype=None):
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
self.exists = False
|
||||
self.mimetype = None
|
||||
self.encoding = None
|
||||
@@ -89,6 +90,8 @@ class OfficeConverterBackendDirect(object):
|
||||
"""
|
||||
Executes libreoffice using subprocess's Popen
|
||||
"""
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
self.input_filepath = input_filepath
|
||||
self.output_filepath = output_filepath
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import os
|
||||
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
|
||||
def document_save_to_temp_dir(document, filename, buffer_size=1024 * 1024):
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
temporary_path = os.path.join(TEMPORARY_DIRECTORY, filename)
|
||||
return document.save_to_file(temporary_path, buffer_size)
|
||||
|
||||
@@ -11,7 +11,6 @@ from converter.office_converter import OfficeConverter
|
||||
from converter.exceptions import OfficeConversionError
|
||||
from documents.utils import document_save_to_temp_dir
|
||||
from common.utils import copyfile
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
from common.textparser import TextParser as OriginalTextParser, TEXT_PARSER_MIMETYPES
|
||||
|
||||
from ocr.parsers.exceptions import ParserError, ParserUnknownFile
|
||||
@@ -127,6 +126,8 @@ class PopplerParser(Parser):
|
||||
logger.debug('self.pdftotext_path: %s' % self.pdftotext_path)
|
||||
|
||||
def parse(self, document_page, descriptor=None):
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
logger.debug('parsing PDF with PopplerParser')
|
||||
pagenum = str(document_page.page_number)
|
||||
|
||||
@@ -168,6 +169,8 @@ class PopplerParser(Parser):
|
||||
|
||||
class TextParser(Parser):
|
||||
def parse(self, document_page, descriptor=None):
|
||||
from common.settings import TEMPORARY_DIRECTORY
|
||||
|
||||
logger.debug('parsing with TextParser')
|
||||
pagenum = str(document_page.page_number)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user