IO4IT 0.0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- IO4IT-0.0.0.1/IO4IT.egg-info/PKG-INFO +8 -0
- IO4IT-0.0.0.1/IO4IT.egg-info/SOURCES.txt +23 -0
- IO4IT-0.0.0.1/IO4IT.egg-info/dependency_links.txt +1 -0
- IO4IT-0.0.0.1/IO4IT.egg-info/entry_points.txt +2 -0
- IO4IT-0.0.0.1/IO4IT.egg-info/namespace_packages.txt +1 -0
- IO4IT-0.0.0.1/IO4IT.egg-info/requires.txt +2 -0
- IO4IT-0.0.0.1/IO4IT.egg-info/top_level.txt +1 -0
- IO4IT-0.0.0.1/License.txt +6 -0
- IO4IT-0.0.0.1/PKG-INFO +8 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/__init__.py +0 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/OWS3downloader.py +94 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/OWS3list.py +107 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/OWwordpdf2docx.py +126 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/__init__.py +19 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/designer/__init__.py +0 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/designer/wordpdf2docx.ui +41 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/icons/__init__.py +0 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/icons/category.svg +50 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/icons/list_aws.png +0 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/icons/upload.png +0 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/ocr_function/__init__.py +0 -0
- IO4IT-0.0.0.1/orangecontrib/IOIT/widgets/ocr_function/word_converter.py +81 -0
- IO4IT-0.0.0.1/setup.cfg +4 -0
- IO4IT-0.0.0.1/setup.py +58 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
License.txt
|
|
2
|
+
setup.cfg
|
|
3
|
+
setup.py
|
|
4
|
+
IO4IT.egg-info/PKG-INFO
|
|
5
|
+
IO4IT.egg-info/SOURCES.txt
|
|
6
|
+
IO4IT.egg-info/dependency_links.txt
|
|
7
|
+
IO4IT.egg-info/entry_points.txt
|
|
8
|
+
IO4IT.egg-info/namespace_packages.txt
|
|
9
|
+
IO4IT.egg-info/requires.txt
|
|
10
|
+
IO4IT.egg-info/top_level.txt
|
|
11
|
+
orangecontrib/IOIT/__init__.py
|
|
12
|
+
orangecontrib/IOIT/widgets/OWS3downloader.py
|
|
13
|
+
orangecontrib/IOIT/widgets/OWS3list.py
|
|
14
|
+
orangecontrib/IOIT/widgets/OWwordpdf2docx.py
|
|
15
|
+
orangecontrib/IOIT/widgets/__init__.py
|
|
16
|
+
orangecontrib/IOIT/widgets/designer/__init__.py
|
|
17
|
+
orangecontrib/IOIT/widgets/designer/wordpdf2docx.ui
|
|
18
|
+
orangecontrib/IOIT/widgets/icons/__init__.py
|
|
19
|
+
orangecontrib/IOIT/widgets/icons/category.svg
|
|
20
|
+
orangecontrib/IOIT/widgets/icons/list_aws.png
|
|
21
|
+
orangecontrib/IOIT/widgets/icons/upload.png
|
|
22
|
+
orangecontrib/IOIT/widgets/ocr_function/__init__.py
|
|
23
|
+
orangecontrib/IOIT/widgets/ocr_function/word_converter.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
orangecontrib
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
orangecontrib
|
IO4IT-0.0.0.1/PKG-INFO
ADDED
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import boto3
|
|
3
|
+
from Orange.widgets.widget import OWWidget, Input
|
|
4
|
+
from Orange.widgets.settings import Setting
|
|
5
|
+
from Orange.widgets import gui
|
|
6
|
+
from AnyQt.QtWidgets import QLineEdit, QFileDialog,QApplication
|
|
7
|
+
from Orange.data import Table, Domain, StringVariable, ContinuousVariable
|
|
8
|
+
|
|
9
|
+
class OWS3FileDownloader(OWWidget):
|
|
10
|
+
name = "S3 File Downloader"
|
|
11
|
+
description = "Télécharge les fichiers listés depuis S3 vers un répertoire local."
|
|
12
|
+
icon = "icons/download.png"
|
|
13
|
+
if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
|
|
14
|
+
icon = "icons_dev/download.png"
|
|
15
|
+
priority = 20
|
|
16
|
+
|
|
17
|
+
# Paramètres utilisateur
|
|
18
|
+
access_key = Setting("")
|
|
19
|
+
secret_key = Setting("")
|
|
20
|
+
bucket_name = Setting("")
|
|
21
|
+
download_path = Setting("")
|
|
22
|
+
|
|
23
|
+
class Inputs:
|
|
24
|
+
data = Input("Data", Table)
|
|
25
|
+
|
|
26
|
+
def __init__(self):
|
|
27
|
+
super().__init__()
|
|
28
|
+
self.data = None
|
|
29
|
+
|
|
30
|
+
# Interface utilisateur
|
|
31
|
+
self.access_key_input = QLineEdit(self)
|
|
32
|
+
self.access_key_input.setPlaceholderText("AWS Access Key")
|
|
33
|
+
self.access_key_input.setText(self.access_key)
|
|
34
|
+
self.access_key_input.editingFinished.connect(self.update_settings)
|
|
35
|
+
gui.widgetBox(self.controlArea, orientation='vertical').layout().addWidget(self.access_key_input)
|
|
36
|
+
|
|
37
|
+
self.secret_key_input = QLineEdit(self)
|
|
38
|
+
self.secret_key_input.setPlaceholderText("AWS Secret Key")
|
|
39
|
+
self.secret_key_input.setText(self.secret_key)
|
|
40
|
+
self.secret_key_input.editingFinished.connect(self.update_settings)
|
|
41
|
+
gui.widgetBox(self.controlArea, orientation='vertical').layout().addWidget(self.secret_key_input)
|
|
42
|
+
|
|
43
|
+
self.bucket_input = QLineEdit(self)
|
|
44
|
+
self.bucket_input.setPlaceholderText("Bucket S3")
|
|
45
|
+
self.bucket_input.setText(self.bucket_name)
|
|
46
|
+
self.bucket_input.editingFinished.connect(self.update_settings)
|
|
47
|
+
gui.widgetBox(self.controlArea, orientation='vertical').layout().addWidget(self.bucket_input)
|
|
48
|
+
|
|
49
|
+
self.path_button = gui.button(self.controlArea, self, "Choisir un répertoire", callback=self.select_directory)
|
|
50
|
+
|
|
51
|
+
gui.button(self.controlArea, self, "Télécharger les fichiers", callback=self.download_files)
|
|
52
|
+
|
|
53
|
+
def update_settings(self):
|
|
54
|
+
self.access_key = self.access_key_input.text()
|
|
55
|
+
self.secret_key = self.secret_key_input.text()
|
|
56
|
+
self.bucket_name = self.bucket_input.text()
|
|
57
|
+
|
|
58
|
+
def select_directory(self):
|
|
59
|
+
directory = QFileDialog.getExistingDirectory(self, "Sélectionner un répertoire")
|
|
60
|
+
if directory:
|
|
61
|
+
self.download_path = directory
|
|
62
|
+
|
|
63
|
+
@Inputs.data
|
|
64
|
+
def set_data(self, data):
|
|
65
|
+
self.data = data
|
|
66
|
+
|
|
67
|
+
def download_files(self):
|
|
68
|
+
if self.data is None:
|
|
69
|
+
self.error("Aucune donnée reçue.")
|
|
70
|
+
return
|
|
71
|
+
|
|
72
|
+
if not self.download_path:
|
|
73
|
+
self.error("Veuillez choisir un répertoire de téléchargement.")
|
|
74
|
+
return
|
|
75
|
+
|
|
76
|
+
try:
|
|
77
|
+
session = boto3.Session(
|
|
78
|
+
aws_access_key_id=self.access_key,
|
|
79
|
+
aws_secret_access_key=self.secret_key
|
|
80
|
+
)
|
|
81
|
+
s3 = session.client("s3")
|
|
82
|
+
for elem in self.data:
|
|
83
|
+
file_key = elem["Nom"].value
|
|
84
|
+
local_file_path = os.path.join(self.download_path, file_key)
|
|
85
|
+
|
|
86
|
+
os.makedirs(os.path.dirname(local_file_path), exist_ok=True)
|
|
87
|
+
s3.download_file(self.bucket_name, file_key, local_file_path)
|
|
88
|
+
self.information("Téléchargement terminé !")
|
|
89
|
+
|
|
90
|
+
except Exception as e:
|
|
91
|
+
print(e)
|
|
92
|
+
self.error(str(e))
|
|
93
|
+
|
|
94
|
+
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import boto3
|
|
2
|
+
from Orange.widgets.widget import OWWidget, Input, Output
|
|
3
|
+
from Orange.widgets.settings import Setting
|
|
4
|
+
from Orange.widgets import gui
|
|
5
|
+
from AnyQt.QtWidgets import QLineEdit, QApplication
|
|
6
|
+
from Orange.data import Table, Domain, StringVariable, ContinuousVariable
|
|
7
|
+
import os
|
|
8
|
+
|
|
9
|
+
class OWS3FileLister(OWWidget):
|
|
10
|
+
name = "S3 File Lister"
|
|
11
|
+
description = "Liste les fichiers d'un bucket S3 et affiche leurs détails."
|
|
12
|
+
icon = "icons/list_aws.png"
|
|
13
|
+
if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
|
|
14
|
+
icon = "icons_dev/list_aws.png"
|
|
15
|
+
priority = 10
|
|
16
|
+
|
|
17
|
+
# Paramètres utilisateur
|
|
18
|
+
access_key = Setting("")
|
|
19
|
+
secret_key = Setting("")
|
|
20
|
+
bucket_name = Setting("")
|
|
21
|
+
allowed_extensions = Setting("*")
|
|
22
|
+
folder_name = Setting("")
|
|
23
|
+
|
|
24
|
+
class Outputs:
|
|
25
|
+
data = Output("Data", Table)
|
|
26
|
+
|
|
27
|
+
def __init__(self):
|
|
28
|
+
super().__init__()
|
|
29
|
+
|
|
30
|
+
# Interface utilisateur
|
|
31
|
+
self.access_key_input = QLineEdit(self)
|
|
32
|
+
self.access_key_input.setPlaceholderText("AWS Access Key")
|
|
33
|
+
self.access_key_input.setText(self.access_key)
|
|
34
|
+
self.access_key_input.editingFinished.connect(self.update_settings)
|
|
35
|
+
gui.widgetBox(self.controlArea, orientation='vertical').layout().addWidget(self.access_key_input)
|
|
36
|
+
|
|
37
|
+
self.secret_key_input = QLineEdit(self)
|
|
38
|
+
self.secret_key_input.setPlaceholderText("AWS Secret Key")
|
|
39
|
+
self.secret_key_input.setText(self.secret_key)
|
|
40
|
+
self.secret_key_input.editingFinished.connect(self.update_settings)
|
|
41
|
+
gui.widgetBox(self.controlArea, orientation='vertical').layout().addWidget(self.secret_key_input)
|
|
42
|
+
|
|
43
|
+
self.bucket_input = QLineEdit(self)
|
|
44
|
+
self.bucket_input.setPlaceholderText("Bucket S3")
|
|
45
|
+
self.bucket_input.setText(self.bucket_name)
|
|
46
|
+
self.bucket_input.editingFinished.connect(self.update_settings)
|
|
47
|
+
gui.widgetBox(self.controlArea, orientation='vertical').layout().addWidget(self.bucket_input)
|
|
48
|
+
|
|
49
|
+
self.extensions_input = QLineEdit(self)
|
|
50
|
+
self.extensions_input.setPlaceholderText("Extensions files from S3")
|
|
51
|
+
self.extensions_input.setText(",".join(self.allowed_extensions))
|
|
52
|
+
self.extensions_input.editingFinished.connect(self.update_settings)
|
|
53
|
+
gui.widgetBox(self.controlArea, orientation='vertical').layout().addWidget(self.extensions_input)
|
|
54
|
+
|
|
55
|
+
# self.folder_input = QLineEdit(self)
|
|
56
|
+
# self.folder_input.setPlaceholderText("Folder files from S3")
|
|
57
|
+
# self.folder_input.setText(self.folder_name)
|
|
58
|
+
# self.folder_input.editingFinished.connect(self.update_settings)
|
|
59
|
+
# gui.widgetBox(self.controlArea, orientation='vertical').layout().addWidget(self.extensions_input)
|
|
60
|
+
|
|
61
|
+
gui.button(self.controlArea, self, "Lister les fichiers", callback=self.list_files)
|
|
62
|
+
|
|
63
|
+
def update_settings(self):
|
|
64
|
+
self.access_key = self.access_key_input.text()
|
|
65
|
+
self.secret_key = self.secret_key_input.text()
|
|
66
|
+
self.bucket_name = self.bucket_input.text()
|
|
67
|
+
self.allowed_extensions = self.extensions_input.text()
|
|
68
|
+
self.folder_name = self.folder_input.text()
|
|
69
|
+
|
|
70
|
+
def list_files(self):
|
|
71
|
+
self.error(None)
|
|
72
|
+
try:
|
|
73
|
+
session = boto3.Session(
|
|
74
|
+
aws_access_key_id=self.access_key,
|
|
75
|
+
aws_secret_access_key=self.secret_key
|
|
76
|
+
)
|
|
77
|
+
s3 = session.client("s3")
|
|
78
|
+
response = s3.list_objects_v2(Bucket=self.bucket_name, Prefix = self.folder_name)
|
|
79
|
+
if self.allowed_extensions == "*":
|
|
80
|
+
self.allowed_extensions = "*"
|
|
81
|
+
elif isinstance(self.allowed_extensions, str):
|
|
82
|
+
self.allowed_extensions = tuple(ext.strip().lower() for ext in self.allowed_extensions.split(","))
|
|
83
|
+
|
|
84
|
+
if "Contents" in response:
|
|
85
|
+
data = []
|
|
86
|
+
meta = []
|
|
87
|
+
for obj in response["Contents"]:
|
|
88
|
+
if self.allowed_extensions == "*" or self.allowed_extensions == "" or obj["Key"].lower().endswith(self.allowed_extensions):
|
|
89
|
+
data.append([str(obj["Size"])])
|
|
90
|
+
meta.append([obj["Key"],obj["LastModified"].strftime("%Y-%m-%d %H:%M:%S")])
|
|
91
|
+
|
|
92
|
+
domain = Domain(
|
|
93
|
+
[ContinuousVariable("Taille (bytes)")], metas=[StringVariable("Nom"), StringVariable("Date")]
|
|
94
|
+
)
|
|
95
|
+
orange_table = Table.from_numpy(domain, data, metas=meta)
|
|
96
|
+
self.Outputs.data.send(orange_table)
|
|
97
|
+
|
|
98
|
+
except Exception as e:
|
|
99
|
+
self.error(str(e))
|
|
100
|
+
|
|
101
|
+
if __name__ == "__main__":
|
|
102
|
+
import sys
|
|
103
|
+
|
|
104
|
+
app = QApplication(sys.argv)
|
|
105
|
+
window = OWS3FileLister()
|
|
106
|
+
window.show()
|
|
107
|
+
sys.exit(app.exec_())
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
import Orange.data
|
|
5
|
+
from AnyQt.QtWidgets import QApplication
|
|
6
|
+
from Orange.widgets import widget
|
|
7
|
+
from Orange.widgets.utils.signals import Input, Output
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
|
|
11
|
+
from Orange.widgets.orangecontrib.AAIT.utils import thread_management
|
|
12
|
+
from Orange.widgets.orangecontrib.AAIT.utils.import_uic import uic
|
|
13
|
+
from Orange.widgets.orangecontrib.AAIT.utils.initialize_from_ini import apply_modification_from_python_file
|
|
14
|
+
from Orange.widgets.orangecontrib.IOIT.ocr_function import word_converter
|
|
15
|
+
else:
|
|
16
|
+
from orangecontrib.AAIT.utils import thread_management
|
|
17
|
+
from orangecontrib.AAIT.utils.import_uic import uic
|
|
18
|
+
from orangecontrib.AAIT.utils.initialize_from_ini import apply_modification_from_python_file
|
|
19
|
+
from orangecontrib.IOIT.ocr_function import word_converter
|
|
20
|
+
|
|
21
|
+
@apply_modification_from_python_file(filepath_original_widget=__file__)
|
|
22
|
+
class OWCreateEmbeddings(widget.OWWidget):
|
|
23
|
+
name = "WordPdf2Docx"
|
|
24
|
+
description = "Convert pdf from a directory to docx using word"
|
|
25
|
+
icon = "icons/wordpdf2docx.png"
|
|
26
|
+
if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
|
|
27
|
+
icon = "icons_dev/wordpdf2docx.png"
|
|
28
|
+
gui = os.path.join(os.path.dirname(os.path.abspath(__file__)), "designer/wordpdf2docx.ui")
|
|
29
|
+
want_control_area = False
|
|
30
|
+
priority = 3000
|
|
31
|
+
|
|
32
|
+
class Inputs:
|
|
33
|
+
data = Input("Data", Orange.data.Table)
|
|
34
|
+
|
|
35
|
+
class Outputs:
|
|
36
|
+
data = Output("Data", Orange.data.Table)
|
|
37
|
+
|
|
38
|
+
@Inputs.data
|
|
39
|
+
def set_data(self, in_data):
|
|
40
|
+
self.data = in_data
|
|
41
|
+
if self.autorun:
|
|
42
|
+
self.run()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def __init__(self):
|
|
46
|
+
super().__init__()
|
|
47
|
+
# Qt Management
|
|
48
|
+
self.setFixedWidth(470)
|
|
49
|
+
self.setFixedHeight(300)
|
|
50
|
+
uic.loadUi(self.gui, self)
|
|
51
|
+
|
|
52
|
+
# Data Management
|
|
53
|
+
self.data = None
|
|
54
|
+
self.thread = None
|
|
55
|
+
self.autorun = True
|
|
56
|
+
self.result = None
|
|
57
|
+
self.post_initialized()
|
|
58
|
+
|
|
59
|
+
def run(self):
|
|
60
|
+
# if thread is running quit
|
|
61
|
+
if self.thread is not None:
|
|
62
|
+
self.thread.safe_quit()
|
|
63
|
+
|
|
64
|
+
if self.data is None:
|
|
65
|
+
return
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# Verification of in_data
|
|
69
|
+
self.error("")
|
|
70
|
+
try:
|
|
71
|
+
self.data.domain["input_dir"]
|
|
72
|
+
except KeyError:
|
|
73
|
+
self.error('You need a "input_dir" column in input data')
|
|
74
|
+
return
|
|
75
|
+
|
|
76
|
+
if type(self.data.domain["input_dir"]).__name__ != 'StringVariable':
|
|
77
|
+
self.error('"input_dir" column needs to be a Text')
|
|
78
|
+
return
|
|
79
|
+
try:
|
|
80
|
+
self.data.domain["output_dir"]
|
|
81
|
+
except KeyError:
|
|
82
|
+
self.error('You need a "output_dir" column in input data')
|
|
83
|
+
return
|
|
84
|
+
|
|
85
|
+
if type(self.data.domain["output_dir"]).__name__ != 'StringVariable':
|
|
86
|
+
self.error('"output_dir" column needs to be a Text')
|
|
87
|
+
return
|
|
88
|
+
input_dir = self.data.get_column("input_dir")
|
|
89
|
+
output_dir = self.data.get_column("output_dir")
|
|
90
|
+
|
|
91
|
+
# Start progress bar
|
|
92
|
+
self.progressBarInit()
|
|
93
|
+
# Connect and start thread : main function, progress, result and finish
|
|
94
|
+
# --> progress is used in the main function to track progress (with a callback)
|
|
95
|
+
# --> result is used to collect the result from main function
|
|
96
|
+
# --> finish is just an empty signal to indicate that the thread is finished
|
|
97
|
+
self.thread = thread_management.Thread(word_converter.convert_pdf_structure, input_dir, output_dir)
|
|
98
|
+
self.thread.progress.connect(self.handle_progress)
|
|
99
|
+
self.thread.result.connect(self.handle_result)
|
|
100
|
+
self.thread.finish.connect(self.handle_finish)
|
|
101
|
+
self.thread.start()
|
|
102
|
+
|
|
103
|
+
def handle_progress(self, value: float) -> None:
|
|
104
|
+
self.progressBarSet(value)
|
|
105
|
+
|
|
106
|
+
def handle_result(self, result):
|
|
107
|
+
try:
|
|
108
|
+
self.result = result
|
|
109
|
+
self.Outputs.data.send(self.data)
|
|
110
|
+
except Exception as e:
|
|
111
|
+
print("An error occurred when sending out_data:", e)
|
|
112
|
+
self.Outputs.data.send(None)
|
|
113
|
+
return
|
|
114
|
+
|
|
115
|
+
def handle_finish(self):
|
|
116
|
+
print("conversion finished")
|
|
117
|
+
self.progressBarFinished()
|
|
118
|
+
|
|
119
|
+
def post_initialized(self):
|
|
120
|
+
pass
|
|
121
|
+
|
|
122
|
+
if __name__ == "__main__":
|
|
123
|
+
app = QApplication(sys.argv)
|
|
124
|
+
my_widget = OWCreateEmbeddings()
|
|
125
|
+
my_widget.show()
|
|
126
|
+
app.exec_()
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Widgets from Development workflow category
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
# ID = "orangecontrib.AAIT"
|
|
6
|
+
|
|
7
|
+
NAME = "Advanced Artificial Intelligence Tools"
|
|
8
|
+
|
|
9
|
+
# Category icon show in the menu
|
|
10
|
+
ICON = "icons/category.svg"
|
|
11
|
+
|
|
12
|
+
BACKGROUND = "light-green"
|
|
13
|
+
|
|
14
|
+
DESCRIPTION = ("Advanced Artificial Intelligence Tools is a package meant to develop and enable advanced AI "
|
|
15
|
+
"functionalities in Orange Data Mining.")
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# PRIORITY = 6
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<ui version="4.0">
|
|
3
|
+
<class>Form</class>
|
|
4
|
+
<widget class="QWidget" name="Form">
|
|
5
|
+
<property name="geometry">
|
|
6
|
+
<rect>
|
|
7
|
+
<x>0</x>
|
|
8
|
+
<y>0</y>
|
|
9
|
+
<width>470</width>
|
|
10
|
+
<height>300</height>
|
|
11
|
+
</rect>
|
|
12
|
+
</property>
|
|
13
|
+
<property name="windowTitle">
|
|
14
|
+
<string>Form</string>
|
|
15
|
+
</property>
|
|
16
|
+
<widget class="QLabel" name="Description">
|
|
17
|
+
<property name="geometry">
|
|
18
|
+
<rect>
|
|
19
|
+
<x>20</x>
|
|
20
|
+
<y>20</y>
|
|
21
|
+
<width>431</width>
|
|
22
|
+
<height>261</height>
|
|
23
|
+
</rect>
|
|
24
|
+
</property>
|
|
25
|
+
<property name="text">
|
|
26
|
+
<string>convert pdf file to docx from input_dir to output_dir</string>
|
|
27
|
+
</property>
|
|
28
|
+
<property name="textFormat">
|
|
29
|
+
<enum>Qt::AutoText</enum>
|
|
30
|
+
</property>
|
|
31
|
+
<property name="alignment">
|
|
32
|
+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
|
33
|
+
</property>
|
|
34
|
+
<property name="wordWrap">
|
|
35
|
+
<bool>true</bool>
|
|
36
|
+
</property>
|
|
37
|
+
</widget>
|
|
38
|
+
</widget>
|
|
39
|
+
<resources/>
|
|
40
|
+
<connections/>
|
|
41
|
+
</ui>
|
|
File without changes
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<?xml version="1.0" ?>
|
|
2
|
+
|
|
3
|
+
<svg width="800px" height="800px" viewBox="0 0 48 48" data-name="Layer 1" id="Layer_1" xmlns="http://www.w3.org/2000/svg">
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
.cls-1, .cls-2 {
|
|
7
|
+
fill: none;
|
|
8
|
+
stroke: #353535;
|
|
9
|
+
stroke-linecap: round;
|
|
10
|
+
stroke-width: 2px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.cls-1 {
|
|
14
|
+
stroke-linejoin: round;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.cls-2 {
|
|
18
|
+
stroke-miterlimit: 10;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.cls-3 {
|
|
22
|
+
fill: #353535;
|
|
23
|
+
}
|
|
24
|
+
</style>
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import win32com.client
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
|
|
5
|
+
#docx_path = pdf_path.replace(".pdf", ".docx")
|
|
6
|
+
def convert_pdf_structure(input_dir: str, output_dir: str, progress_callback=None):
|
|
7
|
+
"""
|
|
8
|
+
return a string with log in case of error
|
|
9
|
+
Recursively lists all .pdf and .PDF files in the input directory,
|
|
10
|
+
replicates the folder structure in the output directory, and
|
|
11
|
+
creates empty .docx files with the same names.
|
|
12
|
+
|
|
13
|
+
Parameters:
|
|
14
|
+
input_dir (str): Path to the input directory containing PDF files.
|
|
15
|
+
output_dir (str): Path to the output directory where DOCX files will be created.
|
|
16
|
+
"""
|
|
17
|
+
error_log=""
|
|
18
|
+
if os.name != 'nt':
|
|
19
|
+
error_log="version developped for windows computer "
|
|
20
|
+
return error_log
|
|
21
|
+
|
|
22
|
+
nbre_file = 0
|
|
23
|
+
for i, data in enumerate(input_dir):
|
|
24
|
+
input_path = Path(str(input_dir[i]))
|
|
25
|
+
for pdf_file in input_path.rglob("*.pdf"):
|
|
26
|
+
nbre_file += 1
|
|
27
|
+
|
|
28
|
+
k = 1
|
|
29
|
+
for i, data in enumerate(input_dir):
|
|
30
|
+
input_path = Path(str(input_dir[i]))
|
|
31
|
+
output_path = Path(str(output_dir[i]))
|
|
32
|
+
|
|
33
|
+
if not input_path.exists() or not input_path.is_dir():
|
|
34
|
+
print(f"Error: The input directory '{input_dir}' does not exist or is not a directory.")
|
|
35
|
+
return f"Error: The input directory '{input_dir}' does not exist or is not a directory. "
|
|
36
|
+
|
|
37
|
+
for pdf_file in input_path.rglob("*.pdf"): # Recursively search for .pdf and .PDF files
|
|
38
|
+
relative_path = pdf_file.relative_to(input_path) # Get relative path from input root
|
|
39
|
+
new_file_path = output_path / relative_path.with_suffix(".docx") # Change extension to .docx
|
|
40
|
+
|
|
41
|
+
# Create necessary directories in the output folder
|
|
42
|
+
new_file_path.parent.mkdir(parents=True, exist_ok=True)
|
|
43
|
+
if 0!= convert_pdf_to_docx(str(pdf_file),str(new_file_path)):
|
|
44
|
+
if error_log!="":
|
|
45
|
+
error_log+="\n"
|
|
46
|
+
error_log+="error -> "+pdf_file
|
|
47
|
+
if progress_callback is not None:
|
|
48
|
+
progress_value = float(100 * (k) / nbre_file)
|
|
49
|
+
k += 1
|
|
50
|
+
progress_callback(progress_value)
|
|
51
|
+
return error_log
|
|
52
|
+
|
|
53
|
+
def convert_pdf_to_docx(pdf_path,docx_path):
|
|
54
|
+
# return 0 ok return 1 ok
|
|
55
|
+
to_return = 1
|
|
56
|
+
if not os.path.exists(pdf_path):
|
|
57
|
+
print(f"File {pdf_path} doesn t exist.")
|
|
58
|
+
return to_return
|
|
59
|
+
try:
|
|
60
|
+
# Lancer Word
|
|
61
|
+
word = win32com.client.Dispatch("Word.Application")
|
|
62
|
+
word.Visible = True # Mettre à True pour voir Word en action
|
|
63
|
+
word.DisplayAlerts = 0 # Désactiver les alertes et fenêtres
|
|
64
|
+
print(f"Conversion {pdf_path} to {docx_path}...")
|
|
65
|
+
|
|
66
|
+
# Ouvrir le PDF avec les bons paramètres
|
|
67
|
+
doc = word.Documents.Open(pdf_path, ReadOnly=True, ConfirmConversions=False)
|
|
68
|
+
|
|
69
|
+
# Sauvegarder en DOCX
|
|
70
|
+
doc.SaveAs(docx_path, FileFormat=16) # 16 = wdFormatDocumentDefault
|
|
71
|
+
doc.Close(False)
|
|
72
|
+
|
|
73
|
+
print(f"Conversion ok : {docx_path}")
|
|
74
|
+
to_return=0
|
|
75
|
+
except Exception as e:
|
|
76
|
+
print(f"Error : {e}")
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
finally:
|
|
80
|
+
word.Quit()
|
|
81
|
+
return to_return
|
IO4IT-0.0.0.1/setup.cfg
ADDED
IO4IT-0.0.0.1/setup.py
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from setuptools import setup, find_packages
|
|
2
|
+
|
|
3
|
+
# Nom du package PyPI ('pip install NAME')
|
|
4
|
+
NAME = "IO4IT"
|
|
5
|
+
|
|
6
|
+
# Version du package PyPI
|
|
7
|
+
VERSION = "0.0.0.1" # la version doit être supérieure à la précédente sinon la publication sera refusée
|
|
8
|
+
|
|
9
|
+
# Facultatif / Adaptable à souhait
|
|
10
|
+
AUTHOR = ""
|
|
11
|
+
AUTHOR_EMAIL = ""
|
|
12
|
+
URL = ""
|
|
13
|
+
DESCRIPTION = ""
|
|
14
|
+
LICENSE = ""
|
|
15
|
+
|
|
16
|
+
# 'orange3 add-on' permet de rendre l'addon téléchargeable via l'interface addons d'Orange
|
|
17
|
+
KEYWORDS = ["orange3 add-on",]
|
|
18
|
+
|
|
19
|
+
# Tous les packages python existants dans le projet (avec un __ini__.py)
|
|
20
|
+
PACKAGES = find_packages()
|
|
21
|
+
PACKAGES = [pack for pack in PACKAGES if "orangecontrib" in pack and "IOIT" in pack]
|
|
22
|
+
print(PACKAGES)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
# Fichiers additionnels aux fichiers .py (comme les icons ou des .ows)
|
|
27
|
+
PACKAGE_DATA = {
|
|
28
|
+
"orangecontrib.IOIT.widgets": ["icons/*", "designer/*"],
|
|
29
|
+
}
|
|
30
|
+
# /!\ les noms de fichier 'orangecontrib.hkh_bot.widgets' doivent correspondre à l'arborescence
|
|
31
|
+
|
|
32
|
+
# Dépendances
|
|
33
|
+
INSTALL_REQUIRES = ["boto3", "fastapi"]
|
|
34
|
+
|
|
35
|
+
# Spécifie le dossier contenant les widgets et le nom de section qu'aura l'addon sur Orange
|
|
36
|
+
ENTRY_POINTS = {
|
|
37
|
+
"orange.widgets": (
|
|
38
|
+
"Advanced Artificial Intelligence Tools = orangecontrib.AAIT.widgets",
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
# /!\ les noms de fichier 'orangecontrib.hkh_bot.widgets' doivent correspondre à l'arborescence
|
|
42
|
+
|
|
43
|
+
NAMESPACE_PACKAGES = ["orangecontrib"]
|
|
44
|
+
|
|
45
|
+
setup(name=NAME,
|
|
46
|
+
version=VERSION,
|
|
47
|
+
author=AUTHOR,
|
|
48
|
+
author_email=AUTHOR_EMAIL,
|
|
49
|
+
url=URL,
|
|
50
|
+
description=DESCRIPTION,
|
|
51
|
+
license=LICENSE,
|
|
52
|
+
keywords=KEYWORDS,
|
|
53
|
+
packages=PACKAGES,
|
|
54
|
+
package_data=PACKAGE_DATA,
|
|
55
|
+
install_requires=INSTALL_REQUIRES,
|
|
56
|
+
entry_points=ENTRY_POINTS,
|
|
57
|
+
namespace_packages=NAMESPACE_PACKAGES,
|
|
58
|
+
)
|