io4it 0.0.0.12.10__py3-none-any.whl

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.
Files changed (30) hide show
  1. io4it-0.0.0.12.10-py3.11-nspkg.pth +1 -0
  2. io4it-0.0.0.12.10.dist-info/License.txt +6 -0
  3. io4it-0.0.0.12.10.dist-info/METADATA +23 -0
  4. io4it-0.0.0.12.10.dist-info/RECORD +30 -0
  5. io4it-0.0.0.12.10.dist-info/WHEEL +5 -0
  6. io4it-0.0.0.12.10.dist-info/entry_points.txt +2 -0
  7. io4it-0.0.0.12.10.dist-info/namespace_packages.txt +1 -0
  8. io4it-0.0.0.12.10.dist-info/top_level.txt +1 -0
  9. orangecontrib/IO4IT/__init__.py +0 -0
  10. orangecontrib/IO4IT/ocr_function/__init__.py +0 -0
  11. orangecontrib/IO4IT/ocr_function/word_converter.py +327 -0
  12. orangecontrib/IO4IT/widgets/OWMarkdownizer.py +202 -0
  13. orangecontrib/IO4IT/widgets/OWPathPropagator.py +123 -0
  14. orangecontrib/IO4IT/widgets/OWS3Uploader.py +92 -0
  15. orangecontrib/IO4IT/widgets/OWS3downloader.py +94 -0
  16. orangecontrib/IO4IT/widgets/OWS3list.py +107 -0
  17. orangecontrib/IO4IT/widgets/OWSpeechToText.py +362 -0
  18. orangecontrib/IO4IT/widgets/OWwordpdf2docx.py +129 -0
  19. orangecontrib/IO4IT/widgets/__init__.py +19 -0
  20. orangecontrib/IO4IT/widgets/designer/ow_in_or_out_path.ui +85 -0
  21. orangecontrib/IO4IT/widgets/designer/owspeechtotext.ui +104 -0
  22. orangecontrib/IO4IT/widgets/designer/wordpdf2docx.ui +57 -0
  23. orangecontrib/IO4IT/widgets/icons/category.svg +50 -0
  24. orangecontrib/IO4IT/widgets/icons/download.png +0 -0
  25. orangecontrib/IO4IT/widgets/icons/in_or_out.png +0 -0
  26. orangecontrib/IO4IT/widgets/icons/list_aws.png +0 -0
  27. orangecontrib/IO4IT/widgets/icons/md.png +0 -0
  28. orangecontrib/IO4IT/widgets/icons/speech_to_text.png +0 -0
  29. orangecontrib/IO4IT/widgets/icons/upload.png +0 -0
  30. orangecontrib/IO4IT/widgets/icons/wordpdf2docx.png +0 -0
@@ -0,0 +1,123 @@
1
+ import os
2
+ from pathlib import Path
3
+ import tempfile
4
+ import subprocess
5
+ from PyQt5.QtWidgets import QPushButton, QRadioButton, QApplication
6
+ from PyQt5 import uic
7
+ from AnyQt.QtWidgets import QFileDialog, QVBoxLayout, QWidget
8
+
9
+ from Orange.widgets.widget import OWWidget, Output, Input
10
+ from Orange.data import Table, Domain, StringVariable
11
+ from Orange.widgets.settings import Setting
12
+ class OWDirectorySelector(OWWidget):
13
+ name = "Directory Selector"
14
+ description = "Select a folder and assign it as input_dir or output_dir"
15
+ icon = "icons/in_or_out.png"
16
+ if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
17
+ icon = "icons_dev/in_or_out.png"
18
+ gui_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "designer/ow_in_or_out_path.ui")
19
+ priority = 10
20
+
21
+ radio_value = Setting("") # Par défaut
22
+
23
+ class Inputs:
24
+ in_data = Input("Data", Table)
25
+
26
+ class Outputs:
27
+ data = Output("Data", Table)
28
+
29
+ def __init__(self):
30
+ super().__init__()
31
+ self.selected_path = ""
32
+ self.in_data = None
33
+
34
+ # Load UI
35
+ uic.loadUi(self.gui_path, self)
36
+
37
+ # Find widgets
38
+ self.file_button = self.findChild(QPushButton, 'fileButton')
39
+ self.input_dir_button = self.findChild(QRadioButton, 'input_dir')
40
+ self.output_dir_button = self.findChild(QRadioButton, 'output_dir')
41
+
42
+ # Connect signals
43
+ self.file_button.clicked.connect(self.select_folder)
44
+ self.input_dir_button.toggled.connect(self.set_radio_input)
45
+ self.output_dir_button.toggled.connect(self.set_radio_output)
46
+
47
+ if self.radio_value == "input_dir":
48
+ self.input_dir_button.setChecked(True)
49
+ else:
50
+ self.output_dir_button.setChecked(True)
51
+
52
+ @Inputs.in_data
53
+ def set_input_data(self, data):
54
+ self.in_data = data
55
+ if data is not None:
56
+ self.select_folder()
57
+
58
+ def set_radio_input(self):
59
+ self.radio_value = "input_dir"
60
+ self.commit_path()
61
+
62
+ def set_radio_output(self):
63
+ self.radio_value = "output_dir"
64
+ self.commit_path()
65
+
66
+ def select_folder(self):
67
+ vbs_code = '''
68
+ Set objShell = CreateObject("Shell.Application")
69
+ Set objFolder = objShell.BrowseForFolder(0, "Selectionnez un dossier", 1, "")
70
+
71
+ If Not objFolder Is Nothing Then
72
+ folderPath = objFolder.Self.Path
73
+ WScript.Echo folderPath
74
+ End If
75
+ '''
76
+
77
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".vbs", mode="w", encoding="utf-8") as temp_vbs:
78
+ temp_vbs.write(vbs_code)
79
+ temp_vbs_path = temp_vbs.name
80
+
81
+ try:
82
+ completed = subprocess.run(["cscript", "//Nologo", temp_vbs_path], capture_output=True, text=True)
83
+ folder = completed.stdout.strip()
84
+ if folder:
85
+ self.selected_path = folder
86
+ self.commit_path()
87
+ finally:
88
+ os.remove(temp_vbs_path)
89
+
90
+ def commit_path(self):
91
+ if not self.selected_path:
92
+ return
93
+
94
+ col_name = self.radio_value
95
+ var = StringVariable(col_name)
96
+
97
+ if self.in_data is not None:
98
+ domain = Domain(
99
+ self.in_data.domain.attributes,
100
+ self.in_data.domain.class_vars,
101
+ list(self.in_data.domain.metas) + [var]
102
+ )
103
+ new_table = Table.from_table(domain, self.in_data)
104
+ new_meta_column = [self.selected_path] * len(new_table)
105
+ new_table.metas[:, -1] = new_meta_column
106
+ else:
107
+ domain = Domain([], metas=[var])
108
+ new_table = Table(domain, [[]])
109
+ new_table.metas[0] = [self.selected_path]
110
+
111
+ self.Outputs.data.send(new_table)
112
+
113
+ def handleNewSignals(self):
114
+ pass
115
+
116
+
117
+ # Test standalone
118
+ if __name__ == "__main__":
119
+ import sys
120
+ app = QApplication(sys.argv)
121
+ window = OWDirectorySelector()
122
+ window.show()
123
+ sys.exit(app.exec_())
@@ -0,0 +1,92 @@
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
+
10
+ class OWS3FileDownloader(OWWidget):
11
+ name = "S3 File Uploader"
12
+ description = "Envoies les fichiers listés depuis un répertoire local vers s3."
13
+ icon = "icons/upload.png"
14
+ if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
15
+ icon = "icons_dev/upload.png"
16
+ priority = 20
17
+
18
+ # Paramètres utilisateur
19
+ access_key = Setting("")
20
+ secret_key = Setting("")
21
+ bucket_name = Setting("")
22
+ download_path = Setting("")
23
+
24
+ class Inputs:
25
+ data = Input("Data", Table)
26
+
27
+ def __init__(self):
28
+ super().__init__()
29
+ self.data = None
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, "Envoyer les fichiers dans s3", callback=self.upload_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 upload_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
+ files = os.listdir(self.download_path) # Liste tout (fichiers + dossiers)
83
+ files_only = [f for f in files if os.path.isfile(os.path.join(self.download_path, f))]
84
+
85
+ for file in files_only:
86
+ s3.upload_file(self.download_path + "/" + file, "ifia", file)
87
+ self.information("Téléchargement terminé !")
88
+ except Exception as e:
89
+ print(e)
90
+ self.error(str(e))
91
+
92
+
@@ -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_())