mail2task 0.6.0__tar.gz → 0.7.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mail2task
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Extract actionable tasks from emails using Python
5
5
  Author: Eby J Kavungal
6
6
  Project-URL: Homepage, https://github.com/EbyJK/mail2task
@@ -143,6 +143,15 @@ mail2task uses spaCy for:
143
143
  - action verb detection
144
144
  - lightweight NLP parsing
145
145
 
146
+ ## `.eml` Email Support
147
+
148
+ mail2task can process raw email files directly.
149
+
150
+ ```bash
151
+ mail2task sample_email.eml --pretty
152
+ ```
153
+
154
+
146
155
  ## Project Structure
147
156
 
148
157
  ```text
@@ -127,6 +127,15 @@ mail2task uses spaCy for:
127
127
  - action verb detection
128
128
  - lightweight NLP parsing
129
129
 
130
+ ## `.eml` Email Support
131
+
132
+ mail2task can process raw email files directly.
133
+
134
+ ```bash
135
+ mail2task sample_email.eml --pretty
136
+ ```
137
+
138
+
130
139
  ## Project Structure
131
140
 
132
141
  ```text
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "mail2task"
7
- version = "0.6.0"
7
+ version = "0.7.0"
8
8
  description = "Extract actionable tasks from emails using Python"
9
9
  authors = [
10
10
  { name="Eby J Kavungal" }
@@ -2,6 +2,7 @@ import argparse
2
2
  import json
3
3
  import csv
4
4
  from .extractor import extract_tasks
5
+ from .email_parser import extract_email_body
5
6
 
6
7
 
7
8
  def save_csv(tasks, output_file):
@@ -57,8 +58,11 @@ def main():
57
58
  args = parser.parse_args()
58
59
 
59
60
  try:
60
- with open(args.file, "r", encoding="utf-8") as f:
61
- content = f.read()
61
+ if args.file.endswith(".eml"):
62
+ content=extract_email_body(args.file)
63
+ else:
64
+ with open(args.file, "r", encoding="utf-8") as f:
65
+ content = f.read()
62
66
 
63
67
  tasks = extract_tasks(content)
64
68
 
@@ -0,0 +1,22 @@
1
+ from email import policy
2
+ from email.parser import BytesParser
3
+
4
+
5
+ def extract_email_body(file_path: str):
6
+ with open(file_path, "rb") as f:
7
+ msg = BytesParser(policy=policy.default).parse(f)
8
+
9
+ # Prefer plain text body
10
+ if msg.is_multipart():
11
+
12
+ for part in msg.walk():
13
+
14
+ content_type = part.get_content_type()
15
+
16
+ if content_type == "text/plain":
17
+ return part.get_content()
18
+
19
+ else:
20
+ return msg.get_content()
21
+
22
+ return ""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mail2task
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Extract actionable tasks from emails using Python
5
5
  Author: Eby J Kavungal
6
6
  Project-URL: Homepage, https://github.com/EbyJK/mail2task
@@ -143,6 +143,15 @@ mail2task uses spaCy for:
143
143
  - action verb detection
144
144
  - lightweight NLP parsing
145
145
 
146
+ ## `.eml` Email Support
147
+
148
+ mail2task can process raw email files directly.
149
+
150
+ ```bash
151
+ mail2task sample_email.eml --pretty
152
+ ```
153
+
154
+
146
155
  ## Project Structure
147
156
 
148
157
  ```text
@@ -2,6 +2,7 @@ README.md
2
2
  pyproject.toml
3
3
  src/mail2task/__init__.py
4
4
  src/mail2task/cli.py
5
+ src/mail2task/email_parser.py
5
6
  src/mail2task/extractor.py
6
7
  src/mail2task/parser.py
7
8
  src/mail2task.egg-info/PKG-INFO
File without changes