io4it 2.1.2.1__tar.gz → 2.1.4__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 (83) hide show
  1. io4it-2.1.4/PKG-INFO +7 -0
  2. io4it-2.1.4/io4it.egg-info/PKG-INFO +7 -0
  3. {io4it-2.1.2.1 → io4it-2.1.4}/io4it.egg-info/SOURCES.txt +0 -1
  4. {io4it-2.1.2.1 → io4it-2.1.4}/io4it.egg-info/requires.txt +1 -1
  5. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWChatGpt.py +12 -11
  6. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWDoclingMarkdownizerSimple.py +8 -9
  7. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWS3Uploader.py +15 -5
  8. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWS3downloader.py +12 -1
  9. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owmailsender.ui +3 -3
  10. {io4it-2.1.2.1 → io4it-2.1.4}/setup.py +2 -2
  11. io4it-2.1.2.1/PKG-INFO +0 -30
  12. io4it-2.1.2.1/io4it.egg-info/PKG-INFO +0 -30
  13. io4it-2.1.2.1/orangecontrib/IO4IT/widgets/designer/OWmailSender.py +0 -155
  14. {io4it-2.1.2.1 → io4it-2.1.4}/io4it.egg-info/dependency_links.txt +0 -0
  15. {io4it-2.1.2.1 → io4it-2.1.4}/io4it.egg-info/entry_points.txt +0 -0
  16. {io4it-2.1.2.1 → io4it-2.1.4}/io4it.egg-info/namespace_packages.txt +0 -0
  17. {io4it-2.1.2.1 → io4it-2.1.4}/io4it.egg-info/top_level.txt +0 -0
  18. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/__init__.py +0 -0
  19. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/ocr_function/__init__.py +0 -0
  20. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/ocr_function/word_converter.py +0 -0
  21. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/utils/__init__.py +0 -0
  22. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/utils/mail.py +0 -0
  23. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/utils/offuscation_basique.py +0 -0
  24. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/utils/pool_exec_utils.py +0 -0
  25. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/utils/utils_md.py +0 -0
  26. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWDeep_Search.py +0 -0
  27. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWExportMarkdown.py +0 -0
  28. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWExtractTablesDocxToCSV.py +0 -0
  29. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWInboxMailMonitoring.py +0 -0
  30. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWMarkdownLoader.py +0 -0
  31. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWMarkdownizer.py +0 -0
  32. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWOfficeNormalizer.py +0 -0
  33. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWPdfType.py +0 -0
  34. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWProcessPoolExecutor.py +0 -0
  35. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWS3list.py +0 -0
  36. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWSpeechToText.py +0 -0
  37. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWmailLoader.py +0 -0
  38. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWmailSender.py +0 -0
  39. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/OWwordpdf2docx.py +0 -0
  40. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/__init__.py +0 -0
  41. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/__init__.py +0 -0
  42. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/nogui.ui +0 -0
  43. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/ow_file_ext_selector.ui +0 -0
  44. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owchatgpt.ui +0 -0
  45. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owdeepsearch.ui +0 -0
  46. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owdoclingasr.ui +0 -0
  47. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owdoclingmarkdownizersimple.ui +0 -0
  48. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owdocxtocsv.ui +0 -0
  49. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owexportmarkdown.ui +0 -0
  50. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owinboxmailmonitoring.ui +0 -0
  51. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owmailloader.ui +0 -0
  52. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owmarkdownizer.ui +0 -0
  53. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owmarkdownloader.ui +0 -0
  54. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owofficenormalizer.ui +0 -0
  55. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owpdftype.ui +0 -0
  56. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owprocesspoolexecutor.ui +0 -0
  57. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owspeechtotext.ui +0 -0
  58. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/owvisualizationer.ui +0 -0
  59. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/designer/wordpdf2docx.ui +0 -0
  60. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/__init__.py +0 -0
  61. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/chatgpt.png +0 -0
  62. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/check_pdf.png +0 -0
  63. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/deepsearch.svg +0 -0
  64. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/dep_md_old.png +0 -0
  65. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/download.png +0 -0
  66. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/export_md.png +0 -0
  67. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/extract_table.png +0 -0
  68. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/file_extensor.png +0 -0
  69. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/list_aws.png +0 -0
  70. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/load_md.png +0 -0
  71. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/mail_loader.png +0 -0
  72. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/mail_writer.png +0 -0
  73. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/md.png +0 -0
  74. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/monitor-email.svg +0 -0
  75. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/office_normalizer.png +0 -0
  76. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/process_pool_executor.png +0 -0
  77. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/speech_to_text.png +0 -0
  78. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/upload.png +0 -0
  79. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/visualizationer.png +0 -0
  80. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons/wordpdf2docx.png +0 -0
  81. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/IO4IT/widgets/icons_dev/__init__.py +0 -0
  82. {io4it-2.1.2.1 → io4it-2.1.4}/orangecontrib/__init__.py +0 -0
  83. {io4it-2.1.2.1 → io4it-2.1.4}/setup.cfg +0 -0
io4it-2.1.4/PKG-INFO ADDED
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.1
2
+ Name: io4it
3
+ Version: 2.1.4
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: 2.1.4
4
+ Home-page:
5
+ Author:
6
+ Author-email:
7
+ Keywords: orange3 add-on
@@ -34,7 +34,6 @@ orangecontrib/IO4IT/widgets/OWmailLoader.py
34
34
  orangecontrib/IO4IT/widgets/OWmailSender.py
35
35
  orangecontrib/IO4IT/widgets/OWwordpdf2docx.py
36
36
  orangecontrib/IO4IT/widgets/__init__.py
37
- orangecontrib/IO4IT/widgets/designer/OWmailSender.py
38
37
  orangecontrib/IO4IT/widgets/designer/__init__.py
39
38
  orangecontrib/IO4IT/widgets/designer/nogui.ui
40
39
  orangecontrib/IO4IT/widgets/designer/ow_file_ext_selector.ui
@@ -7,7 +7,7 @@ docling-core==2.26.3
7
7
  speechbrain
8
8
  whisper
9
9
  whisper-openai
10
- pyannote.audio
10
+ pyannote.audio==3.4.0
11
11
  pyannote-core
12
12
  pypandoc
13
13
  pypandoc-binary
@@ -126,23 +126,24 @@ class ChatGpt(OWWidget):
126
126
  "type": "input_image",
127
127
  "image_url": f"data:{mime};base64,{b64_img}",
128
128
  })
129
- response = client.responses.create(
130
- model=self.model,
131
- input=[
132
- {"role": "system", "content": system_content},
133
- {"role": "user", "content": user_content},
134
- ],
135
- max_output_tokens=self.max_tokens,
136
- # temperature=self.temperature,
137
- )
138
- self.text_response = response.output_text
129
+
130
+ response = client.responses.create(
131
+ model=self.model,
132
+ input=[
133
+ {"role": "system", "content": system_content},
134
+ {"role": "user", "content": user_content},
135
+ ],
136
+ #max_output_tokens=self.max_tokens,
137
+ # temperature=self.temperature,
138
+ )
139
+ self.text_response = response.output_text
140
+
139
141
 
140
142
 
141
143
  if self.text_response is None:
142
144
  self.error("No response from model.")
143
145
 
144
146
  except Exception as e:
145
- print(e)
146
147
  self.error(f"Error: {e}")
147
148
  return
148
149
 
@@ -42,13 +42,14 @@ def _convert_one_file(file_path_str: str):
42
42
  out_dir = src.parent / "conversion_markdown"
43
43
  out_dir.mkdir(parents=True, exist_ok=True)
44
44
  out_md = out_dir / f"{src.stem}.md"
45
+ out_md_str = str(out_md) # Valeur par défaut, sera modifiée si "nok" pour clarité
45
46
 
46
47
  # Si déjà converti : on ne refait pas
47
48
  if out_md.exists():
48
49
  status = "ok"
49
50
  message = "existant: deja converti"
50
51
  duration = time.time() - t0
51
- return [str(src), str(out_md), status, f"{duration:.2f}", message]
52
+ return [str(src), out_md_str, status, f"{duration:.2f}", message]
52
53
 
53
54
  try:
54
55
  # Docling minimal config (inspiré du snippet)
@@ -72,18 +73,15 @@ def _convert_one_file(file_path_str: str):
72
73
  except Exception as e:
73
74
  status = "nok"
74
75
  message = f"{type(e).__name__}: {e}"
75
- # on écrit quand même un trace .md
76
- try:
77
- out_md.write_text(f"[Erreur conversion] {message}", encoding="utf-8")
78
- except Exception:
79
- pass
76
+ # Lignes d'écriture du fichier de trace .md supprimées ici
77
+ out_md_str = "" # Indique qu'aucun fichier de sortie n'a été créé.
80
78
 
81
79
  duration = time.time() - t0
82
- return [str(src), str(out_md), status, f"{duration:.2f}", message]
80
+ return [str(src), out_md_str, status, f"{duration:.2f}", message]
83
81
 
84
82
 
85
83
  class OWDoclingMarkdownizerSimple(widget.OWWidget):
86
- name = "Docling To Markdown"
84
+ name = "Docling To Markdown - v1"
87
85
  description = "Convert DOCX/PPTX/PDF to Markdown via Docling"
88
86
  icon = "icons/md.png"
89
87
  if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
@@ -266,7 +264,8 @@ class OWDoclingMarkdownizerSimple(widget.OWWidget):
266
264
  self.status_update_signal.emit([row[0], row[2], row[4]])
267
265
  except Exception as e:
268
266
  # Gestion des erreurs de la future et envoi
269
- row = [file_path_str, str((Path(file_path_str).parent / 'a_md' / f"{Path(file_path_str).stem}.md")),
267
+ # Note : Dans ce cas, output_md est vide, car _convert_one_file renvoie ""
268
+ row = [file_path_str, "",
270
269
  "nok", "0.00", f"FutureError: {e}"]
271
270
  results.append(row)
272
271
  ws.append(row)
@@ -3,7 +3,7 @@ import boto3
3
3
  from Orange.widgets.widget import OWWidget, Input, Output
4
4
  from Orange.widgets.settings import Setting
5
5
  from Orange.widgets import gui
6
- from AnyQt.QtWidgets import QLineEdit, QFileDialog
6
+ from AnyQt.QtWidgets import QLineEdit, QFileDialog, QApplication
7
7
  from Orange.data import Table
8
8
 
9
9
 
@@ -15,7 +15,6 @@ class OWS3FileDownloader(OWWidget):
15
15
  icon = "icons_dev/upload.png"
16
16
  priority = 20
17
17
  category = "AAIT - API"
18
-
19
18
  # Paramètres utilisateur
20
19
  access_key = Setting("")
21
20
  secret_key = Setting("")
@@ -92,15 +91,26 @@ class OWS3FileDownloader(OWWidget):
92
91
  s3 = session.client("s3")
93
92
  files = os.listdir(self.download_path) # Liste tout (fichiers + dossiers)
94
93
  files_only = [f for f in files if os.path.isfile(os.path.join(self.download_path, f))]
95
- for file in files_only:
96
- s3.upload_file(self.download_path + "/" + file, self.bucket_name, file)
94
+ print("files_only ::: ", files_only)
95
+ #for file in files_only:
96
+ # s3.upload_file(self.download_path + "/" + file, self.bucket_name, file)
97
97
  self.information("Upload terminé !")
98
98
  self.Outputs.data.send(self.data)
99
99
 
100
100
 
101
-
102
101
  except Exception as e:
103
102
  print(e)
104
103
  self.error(str(e))
105
104
 
106
105
 
106
+ if __name__ == "__main__":
107
+ import sys
108
+
109
+ app = QApplication(sys.argv)
110
+ window = OWS3FileDownloader()
111
+ window.show()
112
+
113
+ if hasattr(app, "exec"):
114
+ sys.exit(app.exec())
115
+ else:
116
+ sys.exit(app.exec_())
@@ -3,7 +3,7 @@ import boto3
3
3
  from Orange.widgets.widget import OWWidget, Input
4
4
  from Orange.widgets.settings import Setting
5
5
  from Orange.widgets import gui
6
- from AnyQt.QtWidgets import QLineEdit, QFileDialog
6
+ from AnyQt.QtWidgets import QLineEdit, QFileDialog, QApplication
7
7
  from Orange.data import Table
8
8
 
9
9
  class OWS3FileDownloader(OWWidget):
@@ -93,3 +93,14 @@ class OWS3FileDownloader(OWWidget):
93
93
  self.error(str(e))
94
94
 
95
95
 
96
+ if __name__ == "__main__":
97
+ import sys
98
+
99
+ app = QApplication(sys.argv)
100
+ window = OWS3FileDownloader()
101
+ window.show()
102
+
103
+ if hasattr(app, "exec"):
104
+ sys.exit(app.exec())
105
+ else:
106
+ sys.exit(app.exec_())
@@ -79,7 +79,7 @@
79
79
  <widget class="QLabel" name="label_3">
80
80
  <property name="geometry">
81
81
  <rect>
82
- <x>140</x>
82
+ <x>130</x>
83
83
  <y>3</y>
84
84
  <width>61</width>
85
85
  <height>16</height>
@@ -92,7 +92,7 @@
92
92
  <widget class="QLabel" name="label_4">
93
93
  <property name="geometry">
94
94
  <rect>
95
- <x>250</x>
95
+ <x>230</x>
96
96
  <y>3</y>
97
97
  <width>71</width>
98
98
  <height>16</height>
@@ -132,7 +132,7 @@
132
132
  <widget class="QLabel" name="label">
133
133
  <property name="geometry">
134
134
  <rect>
135
- <x>140</x>
135
+ <x>130</x>
136
136
  <y>40</y>
137
137
  <width>411</width>
138
138
  <height>31</height>
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  # Configuration
4
4
  NAME = "io4it"
5
- VERSION = "2.1.2.1"
5
+ VERSION = "2.1.4"
6
6
 
7
7
  INSTALL_REQUIRES = [
8
8
  "pylatexenc",
@@ -14,7 +14,7 @@ INSTALL_REQUIRES = [
14
14
  "speechbrain",
15
15
  "whisper",
16
16
  "whisper-openai",
17
- "pyannote.audio",
17
+ "pyannote.audio==3.4.0",
18
18
  "pyannote-core",
19
19
  "pypandoc",
20
20
  "pypandoc-binary",
io4it-2.1.2.1/PKG-INFO DELETED
@@ -1,30 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: io4it
3
- Version: 2.1.2.1
4
- Home-page:
5
- Author:
6
- Author-email:
7
- Keywords: orange3 add-on
8
- Requires-Dist: pylatexenc
9
- Requires-Dist: docopt
10
- Requires-Dist: boto3
11
- Requires-Dist: opencv-python-headless==4.6.0.66
12
- Requires-Dist: docling==2.30.0
13
- Requires-Dist: docling-core==2.26.3
14
- Requires-Dist: speechbrain
15
- Requires-Dist: whisper
16
- Requires-Dist: whisper-openai
17
- Requires-Dist: pyannote.audio
18
- Requires-Dist: pyannote-core
19
- Requires-Dist: pypandoc
20
- Requires-Dist: pypandoc-binary
21
- Requires-Dist: scikit-learn
22
- Requires-Dist: openai
23
- Requires-Dist: pip-system-certs==5.0
24
- Requires-Dist: docx2pdf
25
- Requires-Dist: doc2docx
26
- Requires-Dist: msal
27
- Requires-Dist: exchangelib
28
- Requires-Dist: CATEGORIT
29
- Dynamic: keywords
30
- Dynamic: requires-dist
@@ -1,30 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: io4it
3
- Version: 2.1.2.1
4
- Home-page:
5
- Author:
6
- Author-email:
7
- Keywords: orange3 add-on
8
- Requires-Dist: pylatexenc
9
- Requires-Dist: docopt
10
- Requires-Dist: boto3
11
- Requires-Dist: opencv-python-headless==4.6.0.66
12
- Requires-Dist: docling==2.30.0
13
- Requires-Dist: docling-core==2.26.3
14
- Requires-Dist: speechbrain
15
- Requires-Dist: whisper
16
- Requires-Dist: whisper-openai
17
- Requires-Dist: pyannote.audio
18
- Requires-Dist: pyannote-core
19
- Requires-Dist: pypandoc
20
- Requires-Dist: pypandoc-binary
21
- Requires-Dist: scikit-learn
22
- Requires-Dist: openai
23
- Requires-Dist: pip-system-certs==5.0
24
- Requires-Dist: docx2pdf
25
- Requires-Dist: doc2docx
26
- Requires-Dist: msal
27
- Requires-Dist: exchangelib
28
- Requires-Dist: CATEGORIT
29
- Dynamic: keywords
30
- Dynamic: requires-dist
@@ -1,155 +0,0 @@
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
- if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
10
- from Orange.widgets.orangecontrib.AAIT.utils.import_uic import uic
11
- from Orange.widgets.orangecontrib.AAIT.utils.initialize_from_ini import apply_modification_from_python_file
12
- else:
13
- from orangecontrib.AAIT.utils.import_uic import uic
14
- from orangecontrib.AAIT.utils.initialize_from_ini import apply_modification_from_python_file
15
-
16
-
17
- @apply_modification_from_python_file(filepath_original_widget=__file__)
18
- class OWMailSender(widget.OWWidget):
19
- name = "OWMailSender"
20
- description = "Send a mail from AAIT format"
21
- icon = ""
22
- icon = "icons/mail_writer.png"
23
- if "site-packages/Orange/widgets" in os.path.dirname(os.path.abspath(__file__)).replace("\\", "/"):
24
- icon = "icons_dev/mail_writer.png"
25
- gui = os.path.join(os.path.dirname(os.path.abspath(__file__)), "designer/owmailsender.ui")
26
- want_control_area = False
27
- priority = 9999
28
- category = "AAIT - API"
29
-
30
- class Inputs:
31
- data = Input("Data", Orange.data.Table)
32
-
33
- class Outputs:
34
- data = Output("Data", Orange.data.Table)
35
-
36
- @Inputs.data
37
- def set_data(self, in_data):
38
- self.data = in_data
39
- if self.autorun:
40
- self.run()
41
-
42
-
43
- def __init__(self):
44
- super().__init__()
45
- # Qt Management
46
- self.valid_folders=[]
47
- self.can_run = True
48
- self.setFixedWidth(700)
49
- self.setFixedHeight(500)
50
- uic.loadUi(self.gui, self)
51
-
52
- # # Data Management
53
- self.data = None
54
- self.thread = None
55
- self.autorun = True
56
-
57
- # Custom updates
58
- self.post_initialized()
59
-
60
- def run(self):
61
- self.error("")
62
- if self.data is None:
63
- return
64
-
65
- # TODO : Rajouter le content du mail original ?
66
- domain_requirements = ["Sender", "Receiver", "Copy", "Priority", "Title", "Answer"]
67
- for name in domain_requirements:
68
- if not name in self.data.domain:
69
- self.error(f'You need a column "{name}" in your input data.')
70
- return
71
-
72
- for row in self.data:
73
- mail_path = row["Mail path"].value
74
- # TODO : que faire si out_dir_path existe déjà ? pour le moment ça le remplacera juste, est-ce qu'on veut un warning ?
75
- out_dir_path = os.path.dirname(mail_path)
76
- out_mail_path = os.path.join(out_dir_path, "mail.txt")
77
- out_mail_path_ok = os.path.join(out_dir_path, "mail.ok")
78
- os.makedirs(out_dir_path, exist_ok=True)
79
- response_content = self.format_response(row)
80
- with open(out_mail_path, "w", encoding="utf-8") as f:
81
- f.write(response_content)
82
- with open(out_mail_path_ok, "w", encoding="utf-8") as f:
83
- f.write(response_content)
84
- self.Outputs.data.send(self.data)
85
-
86
-
87
- def format_response(self, row):
88
- """
89
- Formats metadata from an Orange Data Table row into a structured text block.
90
-
91
- Extracts specific fields (Receiver, Sender, Copy, Priority, Title, Answer) from the given row,
92
- maps them to standardized tags (eme, des, cop, pri, tit, txt), and returns a string formatted
93
- in the style of metadata headers (e.g., "#$eme : value").
94
-
95
- Parameters:
96
- row (Orange.data.Instance): A single row from an Orange Data Table.
97
-
98
- Returns:
99
- str: A formatted string representing the metadata of the row, ready to be saved or processed.
100
- """
101
- # Gather the metadata from the row instance
102
- sender = self.safe_get(row, "Sender")
103
- receiver = self.safe_get(row, "Receiver")
104
- copy = self.safe_get(row, "Copy")
105
- priority = self.safe_get(row, "Priority")
106
- title = self.safe_get(row, "Title")
107
- answer = self.safe_get(row, "Answer")
108
-
109
- # Format the metadata with proper prefixes
110
- # TODO : ajouter la gestion du content original !
111
- metadata = {
112
- "eme": sender,
113
- "des": receiver,
114
- "cop": copy,
115
- "pri": priority,
116
- "tit": title,
117
- "txt": answer
118
- }
119
-
120
- # Build the text content as a string
121
- txt_content = ""
122
- for key, value in metadata.items():
123
- line = f"#${key} : {value if value is not None else ''}\n"
124
- txt_content += line
125
- return txt_content
126
-
127
-
128
- def safe_get(self, row, name):
129
- """
130
- Safely retrieves the value of a given column from a row in an Orange Data Table.
131
-
132
- Parameters:
133
- row (Orange.data.Instance): A single row from an Orange Table.
134
- name (str): The name of the column to retrieve.
135
-
136
- Returns:
137
- The value of the column if it exists in the table domain, otherwise "Empty".
138
- """
139
- return row[name].value if name in self.data.domain else "Empty"
140
-
141
-
142
- def post_initialized(self):
143
- pass
144
-
145
- if __name__ == "__main__":
146
- app = QApplication(sys.argv)
147
- data = Orange.data.Table("C:/toto_ta_ta_titi/input.tab")
148
- my_widget = OWMailSender()
149
- my_widget.show()
150
- my_widget.set_data(data)
151
-
152
- if hasattr(app, "exec"):
153
- sys.exit(app.exec())
154
- else:
155
- sys.exit(app.exec_())
File without changes
File without changes