Restored support for DOCX
This commit is contained in:
@@ -21,7 +21,8 @@ import gi
|
||||
gi.require_version('GtkSource', '5')
|
||||
gi.require_version('GdkPixbuf', '2.0')
|
||||
from gi.repository import Adw, Gtk, Gdk, GLib, GtkSource, Gio, GdkPixbuf
|
||||
import json, requests, threading, os, re, base64, sys, gettext, locale, subprocess, uuid, shutil, tarfile, tempfile #, docx
|
||||
import json, requests, threading, os, re, base64, sys, gettext, locale, subprocess, uuid, shutil, tarfile, tempfile
|
||||
from docx2python import docx2python
|
||||
from time import sleep
|
||||
from io import BytesIO
|
||||
from PIL import Image
|
||||
@@ -1247,13 +1248,11 @@ Generate a title following these rules:
|
||||
for i, page in enumerate(reader.pages):
|
||||
text += f"\n- Page {i}\n{page.extract_text()}\n"
|
||||
return text
|
||||
#elif file_type == 'docx':
|
||||
#document = docx.Document(file_path)
|
||||
#if len(document.paragraphs) == 0: return None
|
||||
#text = ""
|
||||
#for paragraph in document.paragraphs:
|
||||
#text += f"{paragraph.text}\n"
|
||||
#return text
|
||||
elif file_type == 'docx':
|
||||
text = None
|
||||
with docx2python(file_path) as document:
|
||||
text = document.text
|
||||
return text
|
||||
|
||||
def remove_attached_file(self, button):
|
||||
del self.attachments[button.get_name()]
|
||||
@@ -1276,7 +1275,7 @@ Generate a title following these rules:
|
||||
"plain_text": "document-text-symbolic",
|
||||
"pdf": "document-text-symbolic",
|
||||
"youtube": "play-symbolic",
|
||||
#"docx": "document-text-symbolic"
|
||||
"docx": "document-text-symbolic"
|
||||
}[file_type]
|
||||
)
|
||||
button = Gtk.Button(
|
||||
|
||||
@@ -1019,6 +1019,7 @@
|
||||
<suffix>json</suffix>
|
||||
<suffix>xml</suffix>
|
||||
<suffix>pdf</suffix>
|
||||
<suffix>docx</suffix>
|
||||
<suffix>png</suffix>
|
||||
<suffix>jpeg</suffix>
|
||||
<suffix>jpg</suffix>
|
||||
|
||||
Reference in New Issue
Block a user