|
@ -32,10 +32,7 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable): |
|
|
arquivo = getattr(obj, self.filename) |
|
|
arquivo = getattr(obj, self.filename) |
|
|
|
|
|
|
|
|
if arquivo: |
|
|
if arquivo: |
|
|
try: |
|
|
if not os.path.exists(arquivo.path): |
|
|
arquivo.open() |
|
|
|
|
|
arquivo.close() |
|
|
|
|
|
except OSError: |
|
|
|
|
|
return self.prepared_data |
|
|
return self.prepared_data |
|
|
|
|
|
|
|
|
if not os.path.splitext(arquivo.path)[1][:1]: |
|
|
if not os.path.splitext(arquivo.path)[1][:1]: |
|
@ -43,10 +40,13 @@ class DocumentoAcessorioIndex(indexes.SearchIndex, indexes.Indexable): |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
extracted_data = textract.process( |
|
|
extracted_data = textract.process( |
|
|
arquivo.path).decode( |
|
|
arquivo.path, |
|
|
'utf-8').replace('\n', ' ') |
|
|
language='pt-br').decode('utf-8').replace('\n', ' ') |
|
|
except ExtensionNotSupported: |
|
|
except ExtensionNotSupported: |
|
|
return self.prepared_data |
|
|
return self.prepared_data |
|
|
|
|
|
except Exception: |
|
|
|
|
|
print('Erro inesperado processando arquivo: %s' % arquivo.path) |
|
|
|
|
|
return self.prepared_data |
|
|
|
|
|
|
|
|
extracted_data = extracted_data.replace('\t', ' ') |
|
|
extracted_data = extracted_data.replace('\t', ' ') |
|
|
|
|
|
|
|
|