io4it 0.0.0.13__tar.gz → 1.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.
Files changed (46) hide show
  1. io4it-1.0.0.1/PKG-INFO +7 -0
  2. io4it-1.0.0.1/io4it.egg-info/PKG-INFO +7 -0
  3. {io4it-0.0.0.13 → io4it-1.0.0.1}/io4it.egg-info/SOURCES.txt +14 -7
  4. {io4it-0.0.0.13 → io4it-1.0.0.1}/io4it.egg-info/requires.txt +1 -6
  5. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/OWFileExtSelector.py +279 -0
  6. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/OWMarkdownizer.py +1 -1
  7. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/OWS3Uploader.py +1 -1
  8. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/OWS3downloader.py +1 -1
  9. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/OWSpeechToText.py +3 -5
  10. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/OWVisualizationer.py +73 -0
  11. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/OWmailLoader.py +156 -0
  12. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/designer/chart.html +281 -0
  13. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/designer/nogui.ui +19 -0
  14. io4it-0.0.0.13/orangecontrib/IO4IT/widgets/designer/ow_in_or_out_path.ui → io4it-1.0.0.1/orangecontrib/IO4IT/widgets/designer/ow_file_ext_selector.ui +14 -30
  15. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/designer/owmailloader.ui +32 -0
  16. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/designer/owvisualizationer.ui +56 -0
  17. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/icons/__init__.py +0 -0
  18. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/icons/file_extensor.png +0 -0
  19. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/icons/visualizationer.png +0 -0
  20. io4it-1.0.0.1/orangecontrib/IO4IT/widgets/icons_dev/__init__.py +0 -0
  21. {io4it-0.0.0.13 → io4it-1.0.0.1}/setup.py +2 -20
  22. io4it-0.0.0.13/PKG-INFO +0 -21
  23. io4it-0.0.0.13/io4it.egg-info/PKG-INFO +0 -21
  24. io4it-0.0.0.13/orangecontrib/IO4IT/ocr_function/word_converter.py +0 -334
  25. io4it-0.0.0.13/orangecontrib/IO4IT/widgets/OWPathPropagator.py +0 -123
  26. io4it-0.0.0.13/orangecontrib/IO4IT/widgets/icons/category.svg +0 -50
  27. io4it-0.0.0.13/orangecontrib/IO4IT/widgets/icons/in_or_out.png +0 -0
  28. {io4it-0.0.0.13 → io4it-1.0.0.1}/io4it.egg-info/dependency_links.txt +0 -0
  29. {io4it-0.0.0.13 → io4it-1.0.0.1}/io4it.egg-info/entry_points.txt +0 -0
  30. {io4it-0.0.0.13 → io4it-1.0.0.1}/io4it.egg-info/namespace_packages.txt +0 -0
  31. {io4it-0.0.0.13 → io4it-1.0.0.1}/io4it.egg-info/top_level.txt +0 -0
  32. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/__init__.py +0 -0
  33. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/OWS3list.py +0 -0
  34. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/OWwordpdf2docx.py +0 -0
  35. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/__init__.py +0 -0
  36. {io4it-0.0.0.13/orangecontrib/IO4IT/ocr_function → io4it-1.0.0.1/orangecontrib/IO4IT/widgets/designer}/__init__.py +0 -0
  37. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/designer/owspeechtotext.ui +0 -0
  38. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/designer/wordpdf2docx.ui +0 -0
  39. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/icons/download.png +0 -0
  40. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/icons/list_aws.png +0 -0
  41. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/icons/md.png +0 -0
  42. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/icons/speech_to_text.png +0 -0
  43. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/icons/upload.png +0 -0
  44. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/IO4IT/widgets/icons/wordpdf2docx.png +0 -0
  45. {io4it-0.0.0.13 → io4it-1.0.0.1}/orangecontrib/__init__.py +0 -0
  46. {io4it-0.0.0.13 → io4it-1.0.0.1}/setup.cfg +0 -0
io4it-1.0.0.1/PKG-INFO ADDED
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.1
2
+ Name: io4it
3
+ Version: 1.0.0.1
4
+ Home-page:
5
+ Author:
6
+ Author-email:
7
+ Keywords: orange3 add-on
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.1
2
+ Name: io4it
3
+ Version: 1.0.0.1
4
+ Home-page:
5
+ Author:
6
+ Author-email:
7
+ Keywords: orange3 add-on
@@ -9,24 +9,31 @@ io4it.egg-info/requires.txt
9
9
  io4it.egg-info/top_level.txt
10
10
  orangecontrib/__init__.py
11
11
  orangecontrib/IO4IT/__init__.py
12
- orangecontrib/IO4IT/ocr_function/__init__.py
13
- orangecontrib/IO4IT/ocr_function/word_converter.py
12
+ orangecontrib/IO4IT/widgets/OWFileExtSelector.py
14
13
  orangecontrib/IO4IT/widgets/OWMarkdownizer.py
15
- orangecontrib/IO4IT/widgets/OWPathPropagator.py
16
14
  orangecontrib/IO4IT/widgets/OWS3Uploader.py
17
15
  orangecontrib/IO4IT/widgets/OWS3downloader.py
18
16
  orangecontrib/IO4IT/widgets/OWS3list.py
19
17
  orangecontrib/IO4IT/widgets/OWSpeechToText.py
18
+ orangecontrib/IO4IT/widgets/OWVisualizationer.py
19
+ orangecontrib/IO4IT/widgets/OWmailLoader.py
20
20
  orangecontrib/IO4IT/widgets/OWwordpdf2docx.py
21
21
  orangecontrib/IO4IT/widgets/__init__.py
22
- orangecontrib/IO4IT/widgets/designer/ow_in_or_out_path.ui
22
+ orangecontrib/IO4IT/widgets/designer/__init__.py
23
+ orangecontrib/IO4IT/widgets/designer/chart.html
24
+ orangecontrib/IO4IT/widgets/designer/nogui.ui
25
+ orangecontrib/IO4IT/widgets/designer/ow_file_ext_selector.ui
26
+ orangecontrib/IO4IT/widgets/designer/owmailloader.ui
23
27
  orangecontrib/IO4IT/widgets/designer/owspeechtotext.ui
28
+ orangecontrib/IO4IT/widgets/designer/owvisualizationer.ui
24
29
  orangecontrib/IO4IT/widgets/designer/wordpdf2docx.ui
25
- orangecontrib/IO4IT/widgets/icons/category.svg
30
+ orangecontrib/IO4IT/widgets/icons/__init__.py
26
31
  orangecontrib/IO4IT/widgets/icons/download.png
27
- orangecontrib/IO4IT/widgets/icons/in_or_out.png
32
+ orangecontrib/IO4IT/widgets/icons/file_extensor.png
28
33
  orangecontrib/IO4IT/widgets/icons/list_aws.png
29
34
  orangecontrib/IO4IT/widgets/icons/md.png
30
35
  orangecontrib/IO4IT/widgets/icons/speech_to_text.png
31
36
  orangecontrib/IO4IT/widgets/icons/upload.png
32
- orangecontrib/IO4IT/widgets/icons/wordpdf2docx.png
37
+ orangecontrib/IO4IT/widgets/icons/visualizationer.png
38
+ orangecontrib/IO4IT/widgets/icons/wordpdf2docx.png
39
+ orangecontrib/IO4IT/widgets/icons_dev/__init__.py
@@ -5,11 +5,6 @@ speechbrain
5
5
  whisper
6
6
  whisper-openai
7
7
  pyannote.audio
8
- pyannote.core
8
+ pyannote-core
9
9
  wave
10
10
  scikit-learn
11
-
12
- [cuda]
13
- torch==2.6.0+cu126
14
- torchvision==0.17.2+cu126
15
- torchaudio==2.6.0+cu126
@@ -0,0 +1,279 @@
1
+ import os
2
+ import subprocess
3
+ import tempfile
4
+
5
+ from PyQt5.QtWidgets import QPushButton, QListWidget, QListWidgetItem, QApplication, QLabel, QWidget, QVBoxLayout
6
+ from PyQt5.QtGui import QFont
7
+ from PyQt5.QtCore import Qt, QThread, pyqtSignal, QObject
8
+ from PyQt5 import uic
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
+
13
+
14
+ class FileDialogWorker(QObject):
15
+ finished = pyqtSignal(list)
16
+
17
+ def __init__(self, ps_filter):
18
+ super().__init__()
19
+ self.ps_filter = ps_filter
20
+
21
+ def run(self):
22
+ from PyQt5.QtWidgets import QApplication
23
+ screen = QApplication.primaryScreen().geometry()
24
+ x = screen.x() + (screen.width() // 2) - 400
25
+ y = screen.y() + (screen.height() // 2) - 200
26
+
27
+ ps_code = f"""
28
+ Add-Type -AssemblyName System.Windows.Forms
29
+
30
+ # Créer une nouvelle fenêtre parent invisible
31
+ $parentForm = New-Object System.Windows.Forms.Form -Property @{{
32
+ Size = New-Object System.Drawing.Size(0,0) # Taille minimale
33
+ StartPosition = 'CenterScreen'
34
+ TopMost = $true
35
+ ShowInTaskbar = $false
36
+ FormBorderStyle = 'None'
37
+ Opacity = 0 # Rendre la fenêtre totalement transparente
38
+ }}
39
+
40
+ # Créer la boîte de dialogue de sélection de fichiers
41
+ $openFileDialog = New-Object System.Windows.Forms.OpenFileDialog -Property @{{
42
+ Filter = "{self.ps_filter}"
43
+ Multiselect = $true
44
+ }}
45
+
46
+ # Afficher la boîte de dialogue en tant que fenêtre enfant de $parentForm
47
+ $result = $openFileDialog.ShowDialog($parentForm)
48
+
49
+ # Traiter les fichiers sélectionnés
50
+ if ($result -eq [System.Windows.Forms.DialogResult]::OK) {{
51
+ $selectedFiles = $openFileDialog.FileNames
52
+ foreach ($file in $selectedFiles) {{
53
+ Write-Output $file
54
+ }}
55
+ }}
56
+
57
+ # Fermer la fenêtre parent
58
+ $parentForm.Close()
59
+ """
60
+
61
+ with tempfile.NamedTemporaryFile(delete=False, suffix=".ps1", mode="w", encoding="utf-8") as f:
62
+ f.write(ps_code)
63
+ ps_path = f.name
64
+
65
+ result = subprocess.run(
66
+ ["powershell", "-ExecutionPolicy", "Bypass", "-File", ps_path],
67
+ capture_output=True, text=True
68
+ )
69
+ os.unlink(ps_path)
70
+
71
+ file_paths = [line.strip() for line in result.stdout.strip().splitlines() if line.strip()]
72
+ self.finished.emit(file_paths)
73
+
74
+
75
+ class OWFileExtSelector(OWWidget):
76
+ name = "File Extension Selector"
77
+ description = "Select multiple extensions and files"
78
+ icon = "icons/file_extensor.png"
79
+ if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
80
+ icon = "icons_dev/file_extensor.png"
81
+ category = "AAIT - Input"
82
+ gui_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "designer/ow_file_ext_selector.ui")
83
+ priority = 10
84
+
85
+ selected_extensions = Setting(["*.txt"])
86
+ selected_paths = Setting([])
87
+
88
+ class Inputs:
89
+ in_data = Input("Data", Table)
90
+
91
+ class Outputs:
92
+ data = Output("Data", Table)
93
+
94
+ def __init__(self):
95
+ super().__init__()
96
+ self.in_data = None
97
+ self.overlay = None
98
+
99
+ uic.loadUi(self.gui_path, self)
100
+
101
+ self.extension_list = self.findChild(QListWidget, "listExtensions")
102
+ self.file_button = self.findChild(QPushButton, "fileButton")
103
+
104
+ self.extension_list.setSelectionMode(QListWidget.MultiSelection)
105
+ self.populate_extensions()
106
+ self.restore_selected_extensions()
107
+
108
+ self.file_button.clicked.connect(self.select_files)
109
+ self.extension_list.itemSelectionChanged.connect(self.update_settings)
110
+
111
+ def loadSettings(self):
112
+ super().loadSettings()
113
+
114
+ def update_settings(self):
115
+ self.selected_extensions = self.get_selected_extensions()
116
+ self.saveSettings()
117
+
118
+ def restore_selected_extensions(self):
119
+ for i in range(self.extension_list.count()):
120
+ item = self.extension_list.item(i)
121
+ if item.flags() != Qt.NoItemFlags:
122
+ ext = item.data(Qt.UserRole)
123
+ if ext in self.selected_extensions:
124
+ item.setSelected(True)
125
+ self.update_settings()
126
+
127
+ def restore_selected_paths(self):
128
+ if self.selected_paths:
129
+ self.commit_paths()
130
+
131
+ def populate_extensions(self):
132
+ def add_category(label):
133
+ item = QListWidgetItem(label)
134
+ item.setFlags(Qt.NoItemFlags)
135
+ font = QFont()
136
+ font.setBold(True)
137
+ item.setFont(font)
138
+ item.setForeground(Qt.gray)
139
+ self.extension_list.addItem(item)
140
+
141
+ def add_extension(label, ext):
142
+ item = QListWidgetItem(f" {label}")
143
+ item.setData(Qt.UserRole, ext)
144
+ self.extension_list.addItem(item)
145
+
146
+ extensions = {
147
+ "Documents": [
148
+ ("Text files (*.txt)", "*.txt"),
149
+ ("Word documents (*.docx)", "*.docx"),
150
+ ("PDF files (*.pdf)", "*.pdf"),
151
+ ("Markdown (*.md)", "*.md"),
152
+ ],
153
+ "Tableurs": [
154
+ ("Excel files (*.xlsx)", "*.xlsx"),
155
+ ("CSV files (*.csv)", "*.csv"),
156
+ ],
157
+ "Images": [
158
+ ("JPEG images (*.jpg *.jpeg)", "*.jpg *.jpeg"),
159
+ ("PNG images (*.png)", "*.png"),
160
+ ("GIF images (*.gif)", "*.gif"),
161
+ ("SVG images (*.svg)", "*.svg"),
162
+ ],
163
+ "Audio": [
164
+ ("MP3 (*.mp3)", "*.mp3"),
165
+ ("WAV (*.wav)", "*.wav"),
166
+ ],
167
+ "Vidéo": [
168
+ ("MP4 (*.mp4)", "*.mp4"),
169
+ ("MKV (*.mkv)", "*.mkv"),
170
+ ],
171
+ "Archives": [
172
+ ("ZIP (*.zip)", "*.zip"),
173
+ ("RAR (*.rar)", "*.rar"),
174
+ ("7-Zip (*.7z)", "*.7z"),
175
+ ],
176
+ "Code": [
177
+ ("Python (*.py)", "*.py"),
178
+ ("JSON (*.json)", "*.json"),
179
+ ("HTML (*.html)", "*.html"),
180
+ ("XML (*.xml)", "*.xml"),
181
+ ("OWS (*.ows)", "*.ows"),
182
+ ],
183
+ "Autres": [
184
+ ("All files (*.*)", "*.*")
185
+ ]
186
+ }
187
+
188
+ for category, items in extensions.items():
189
+ add_category(category)
190
+ for label, ext in items:
191
+ add_extension(label, ext)
192
+
193
+ def get_selected_extensions(self):
194
+ selected = [
195
+ item.data(Qt.UserRole)
196
+ for item in self.extension_list.selectedItems()
197
+ if item.flags() != Qt.NoItemFlags
198
+ ]
199
+ return selected
200
+
201
+ def show_overlay(self):
202
+ if not self.overlay:
203
+ self.overlay = QWidget()
204
+ self.overlay.setWindowFlags(
205
+ Qt.FramelessWindowHint |
206
+ Qt.Tool # ← PAS de WindowStaysOnTopHint
207
+ )
208
+ self.overlay.setAttribute(Qt.WA_TranslucentBackground)
209
+ self.overlay.setAttribute(Qt.WA_TransparentForMouseEvents)
210
+ self.overlay.setStyleSheet("background-color: rgba(0, 0, 0, 150);")
211
+
212
+ layout = QVBoxLayout(self.overlay)
213
+ message = QLabel("Veuillez sélectionner un fichier...")
214
+ message.setStyleSheet("color: white; font-size: 24px;")
215
+ message.setAlignment(Qt.AlignCenter)
216
+ layout.addWidget(message)
217
+ self.overlay.setLayout(layout)
218
+
219
+ screen_geometry = QApplication.primaryScreen().geometry()
220
+ self.overlay.setGeometry(screen_geometry)
221
+ self.overlay.show()
222
+
223
+ QApplication.processEvents()
224
+
225
+ def hide_overlay(self):
226
+ if self.overlay:
227
+ self.overlay.hide()
228
+ self.overlay = None
229
+
230
+ def select_files(self):
231
+ self.show_overlay()
232
+
233
+ selected_exts = self.get_selected_extensions()
234
+ if not selected_exts:
235
+ self.warning("Please select at least one extension.")
236
+ self.hide_overlay()
237
+ return
238
+
239
+ all_patterns = ";".join(selected_exts)
240
+ ps_filter = f"Supported files ({all_patterns})|{all_patterns}"
241
+
242
+ self.thread = QThread()
243
+ self.worker = FileDialogWorker(ps_filter)
244
+ self.worker.moveToThread(self.thread)
245
+
246
+ self.thread.started.connect(self.worker.run)
247
+ self.worker.finished.connect(self.on_files_selected)
248
+ self.worker.finished.connect(self.thread.quit)
249
+ self.worker.finished.connect(self.worker.deleteLater)
250
+ self.thread.finished.connect(self.thread.deleteLater)
251
+
252
+ self.thread.start()
253
+
254
+ def on_files_selected(self, file_paths):
255
+ self.hide_overlay()
256
+ if file_paths:
257
+ self.selected_paths = file_paths
258
+ self.commit_paths()
259
+
260
+ def commit_paths(self):
261
+ var = StringVariable("file_path")
262
+ domain = Domain([], metas=[var])
263
+ table = Table(domain, [[p] for p in self.selected_paths])
264
+ self.Outputs.data.send(table)
265
+
266
+ @Inputs.in_data
267
+ def set_input_data(self, data):
268
+ self.in_data = data
269
+
270
+ def handleNewSignals(self):
271
+ pass
272
+
273
+
274
+ if __name__ == "__main__":
275
+ import sys
276
+ app = QApplication(sys.argv)
277
+ ow = OWFileExtSelector()
278
+ ow.show()
279
+ sys.exit(app.exec_())
@@ -4,7 +4,7 @@ import urllib.parse
4
4
  from pathlib import Path
5
5
 
6
6
  from PyQt5.QtCore import QThread, pyqtSignal
7
- from AnyQt.QtWidgets import QApplication, QLabel, QPushButton, QProgressBar, QListWidget, QListWidgetItem
7
+ from AnyQt.QtWidgets import QApplication, QLabel, QPushButton, QProgressBar, QListWidget
8
8
 
9
9
  import Orange.data
10
10
  from Orange.widgets import widget
@@ -4,7 +4,7 @@ from Orange.widgets.widget import OWWidget, Input
4
4
  from Orange.widgets.settings import Setting
5
5
  from Orange.widgets import gui
6
6
  from AnyQt.QtWidgets import QLineEdit, QFileDialog,QApplication
7
- from Orange.data import Table, Domain, StringVariable, ContinuousVariable
7
+ from Orange.data import Table
8
8
 
9
9
 
10
10
  class OWS3FileDownloader(OWWidget):
@@ -4,7 +4,7 @@ from Orange.widgets.widget import OWWidget, Input
4
4
  from Orange.widgets.settings import Setting
5
5
  from Orange.widgets import gui
6
6
  from AnyQt.QtWidgets import QLineEdit, QFileDialog,QApplication
7
- from Orange.data import Table, Domain, StringVariable, ContinuousVariable
7
+ from Orange.data import Table
8
8
 
9
9
  class OWS3FileDownloader(OWWidget):
10
10
  name = "S3 File Downloader"
@@ -4,7 +4,6 @@ import os
4
4
  import wave
5
5
  import tempfile
6
6
  import shutil
7
- import os
8
7
  from PyQt5.QtCore import QThread, pyqtSignal
9
8
  from PyQt5.QtWidgets import QApplication, QTextEdit, QPushButton, QSpinBox
10
9
  from pyannote.audio import Audio
@@ -32,10 +31,9 @@ import subprocess
32
31
 
33
32
  def convert_audio_to_pcm(file_path, ffmpeg_path):
34
33
  try:
35
- import subprocess
36
34
 
37
35
  ext = os.path.splitext(file_path)[1].lower()
38
- if ext not in [".mp3", ".wav"]:
36
+ if ext not in [".mp3", ".wav", ".m4a"]:
39
37
  print(f"[ERREUR] Type de fichier non supporté : {ext}")
40
38
  return None
41
39
 
@@ -214,7 +212,7 @@ class OWSpeech_To_Text(widget.OWWidget):
214
212
  self.num_speakers = 4 # spin box a defaut 4
215
213
 
216
214
  self.local_store_path = get_local_store_path()
217
- model_name = "large-v3-turbo.pt"
215
+ model_name = "small.pt"
218
216
  self.embedding_model_name = "spkrec-ecapa-voxceleb"
219
217
  self.model_path = os.path.join(self.local_store_path, "Models", "S2T", model_name)
220
218
  self.embedding_model_path = os.path.join(self.local_store_path, "Models", "S2T", self.embedding_model_name)
@@ -291,7 +289,7 @@ class OWSpeech_To_Text(widget.OWWidget):
291
289
  self.num_speakers = value
292
290
 
293
291
  def select_file(self):
294
- file_path = SimpleDialogQt.BoxSelectExistingFile(self, extention="Audio files (*.wav *.mp3)")
292
+ file_path = SimpleDialogQt.BoxSelectExistingFile(self, extention="Audio files (*.wav *.mp3 *.m4a)")
295
293
 
296
294
  if file_path:
297
295
  # 🔃 Copie dans un chemin sans accents ni caractères spéciaux
@@ -0,0 +1,73 @@
1
+ import os
2
+ from PyQt5.QtWidgets import QPushButton, QListWidget, QListWidgetItem, QApplication, QWidget, QVBoxLayout, QSizePolicy
3
+ from PyQt5.QtGui import QFont
4
+ from PyQt5.QtCore import Qt
5
+ from PyQt5 import uic
6
+ from AnyQt.QtWidgets import QFileDialog
7
+ from Orange.widgets.widget import OWWidget, Output, Input
8
+ from Orange.data import Table, Domain, StringVariable
9
+ from Orange.widgets.settings import Setting
10
+
11
+ if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
12
+ from orangecontrib.AAIT.utils.import_uic import uic
13
+ from orangecontrib.AAIT.utils import SimpleDialogQt
14
+ from orangecontrib.AAIT.utils.MetManagement import get_local_store_path, GetFromRemote
15
+ else:
16
+ from orangecontrib.AAIT.utils.import_uic import uic
17
+ from orangecontrib.AAIT.utils import SimpleDialogQt
18
+ from orangecontrib.AAIT.utils.MetManagement import get_local_store_path, GetFromRemote
19
+
20
+ from PyQt5.QtWebEngineWidgets import QWebEngineView
21
+ from PyQt5.QtCore import QUrl
22
+
23
+
24
+ class OWFileExtSelector(OWWidget):
25
+ name = "Javascript visualization"
26
+ description = "Select multiple extensions and files"
27
+ icon = "icons/visualizationer.png"
28
+ if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
29
+ icon = "icons_dev/visualizationer.png"
30
+ category = "AAIT - Input"
31
+ gui_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "designer/owvisualizationer.ui")
32
+ priority = 10
33
+
34
+
35
+ class Inputs:
36
+ in_data = Input("Data", Table)
37
+
38
+ class Outputs:
39
+ data = Output("Data", Table)
40
+
41
+ def __init__(self):
42
+ super().__init__()
43
+ self.in_data = None
44
+
45
+ # Load UI
46
+ uic.loadUi(self.gui_path, self)
47
+
48
+ self.web_frame = self.findChild(QWidget, "webFrame") # Doit exister dans le .ui
49
+ self.web_view = QWebEngineView(self.web_frame)
50
+ self.web_view.setMinimumSize(400, 300)
51
+ self.web_view.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
52
+
53
+ # Crée un layout si nécessaire
54
+ layout = QVBoxLayout(self.web_frame)
55
+ layout.setContentsMargins(0, 0, 0, 0)
56
+ layout.addWidget(self.web_view)
57
+
58
+ # Charge ton fichier HTML local
59
+ html_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "designer/chart.html"))
60
+ self.web_view.load(QUrl.fromLocalFile(html_path))
61
+
62
+
63
+ @Inputs.in_data
64
+ def set_input_data(self, data):
65
+ self.in_data = data
66
+
67
+
68
+ if __name__ == "__main__":
69
+ import sys
70
+ app = QApplication(sys.argv)
71
+ ow = OWFileExtSelector()
72
+ ow.show()
73
+ sys.exit(app.exec_())
@@ -0,0 +1,156 @@
1
+ import os
2
+ import sys
3
+ from Orange.data import Domain, StringVariable, Table
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
+ else:
15
+ from orangecontrib.AAIT.utils import thread_management
16
+ from orangecontrib.AAIT.utils.import_uic import uic
17
+ from orangecontrib.AAIT.utils.initialize_from_ini import apply_modification_from_python_file
18
+
19
+
20
+ @apply_modification_from_python_file(filepath_original_widget=__file__)
21
+ class OWMailLoader(widget.OWWidget):
22
+ name = "OWMailLoader"
23
+ description = "Load a mail from AAIT format"
24
+ icon = ""
25
+ #if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
26
+ # icon = "icons_dev/owqueryllm.svg"
27
+ gui = os.path.join(os.path.dirname(os.path.abspath(__file__)), "designer/owmailloader.ui")
28
+ want_control_area = True
29
+ priority = 9999
30
+
31
+ class Inputs:
32
+ data = Input("Data", Orange.data.Table)
33
+
34
+ class Outputs:
35
+ data_out_all_dir = Output("Data Out All Dir", Orange.data.Table)
36
+ data_out_nothing_to_do=Output("Data Out Nothing to Do", Orange.data.Table)
37
+
38
+ @Inputs.data
39
+ def set_data(self, in_data):
40
+ self.valid_folders=[]
41
+ input_dir_path=""
42
+ self.error("")
43
+ if in_data is None:
44
+ return
45
+ if not "input_dir" in in_data.domain:
46
+ self.error("need input_dir in input data domain" )
47
+ return
48
+ if len(in_data)!=1:
49
+ self.error("in data need to be exactly 1 line" )
50
+ return
51
+ input_dir_path=str(in_data[0]["input_dir"].value)
52
+ input_dir_path.replace ("\\","/")
53
+
54
+ self.valid_folders=self.get_valid_folders(input_dir_path)
55
+ if len(self.valid_folders)==0:
56
+ self.send_nothing_to_do()
57
+ return
58
+ print( self.valid_folders)
59
+ self.run()
60
+
61
+
62
+ def __init__(self):
63
+ super().__init__()
64
+ # Qt Management
65
+ self.valid_folders=[]
66
+ self.can_run = True
67
+ self.setFixedWidth(700)
68
+ self.setFixedHeight(500)
69
+ uic.loadUi(self.gui, self)
70
+
71
+
72
+
73
+
74
+ # # Data Management
75
+ self.thread = None
76
+
77
+ # Custom updates
78
+ self.post_initialized()
79
+
80
+
81
+
82
+ def get_valid_folders(self,input_dir_path):
83
+ in_dir = os.path.join(input_dir_path, "in")
84
+
85
+ # Étape 1 : Vérifier si le dossier existe
86
+ if not os.path.isdir(in_dir):
87
+ print(f"Dossier introuvable : {in_dir}")
88
+ return [] # ou `return` selon ton besoin
89
+
90
+ # Étape 2 : Parcourir les sous-dossiers
91
+ valid_folders = []
92
+ for name in os.listdir(in_dir):
93
+ full_path = os.path.join(in_dir, name)
94
+ if os.path.isdir(full_path):
95
+ mail_ok_path = os.path.join(full_path, "mail.ok")
96
+ if os.path.isfile(mail_ok_path):
97
+ valid_folders.append(full_path.replace("\\","/"))
98
+
99
+ return valid_folders
100
+ def send_nothing_to_do(self):
101
+
102
+ # Définir une variable texte comme méta-attribut
103
+ text_meta = StringVariable("nothing to do")
104
+
105
+ # Créer un domaine sans variables principales, avec une méta
106
+ domain = Domain([], metas=[text_meta])
107
+
108
+ # Créer la table avec Table.from_list
109
+ data_table = Table.from_list(domain, [["nothing"]])
110
+ self.Outputs.data_out_nothing_to_do.send(data_table)
111
+
112
+ def run(self):
113
+ # Définir les variables de texte
114
+ var_mail_txt = StringVariable("mail_path")
115
+ var_pj_list = StringVariable("pj_files")
116
+
117
+ # Définir le domaine avec deux colonnes texte
118
+ domain = Domain([], metas=[var_mail_txt, var_pj_list])
119
+
120
+ # Construire les lignes de données
121
+ rows = []
122
+ for folder in self.valid_folders:
123
+ # Chemin vers mail.txt
124
+ mail_path = os.path.join(folder, "mail.txt")
125
+
126
+ # Chemin vers le sous-dossier "pj"
127
+ pj_path = os.path.join(folder, "pj")
128
+
129
+ # Lister les fichiers dans pj (ou chaîne vide s'il n'existe pas)
130
+ if os.path.isdir(pj_path):
131
+ files = os.listdir(pj_path)
132
+ else:
133
+ files = []
134
+
135
+ # Convertir la liste de fichiers en chaîne (ex : "file1.pdf, file2.docx")
136
+ files_str = ", ".join(files)
137
+ files_str='['+files_str+']'
138
+ # Ajouter la ligne
139
+ rows.append([mail_path, files_str])
140
+
141
+ # Créer la table Orange
142
+ data_table = Table.from_list(domain, rows)
143
+
144
+ # Afficher la table
145
+ self.Outputs.data_out_all_dir.send(data_table)
146
+
147
+ def post_initialized(self):
148
+ pass
149
+
150
+ if __name__ == "__main__":
151
+ app = QApplication(sys.argv)
152
+ data = Orange.data.Table("C:/toto_ta_ta_titi/input.tab")
153
+ my_widget = OWMailLoader()
154
+ my_widget.show()
155
+ my_widget.set_data(data)
156
+ app.exec_()