mail2task 0.1.0__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.
mail2task/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from .extractor import extract_tasks
mail2task/cli.py ADDED
@@ -0,0 +1,25 @@
1
+ import sys
2
+ import json
3
+ from .extractor import extract_tasks
4
+
5
+
6
+ def main():
7
+ if len(sys.argv) < 2:
8
+ print("Usage: mail2task <file>")
9
+ return
10
+
11
+ file_path = sys.argv[1]
12
+
13
+ try:
14
+ with open(file_path, "r", encoding="utf-8") as f:
15
+ content = f.read()
16
+
17
+ tasks = extract_tasks(content)
18
+
19
+ print(json.dumps(tasks, indent=2))
20
+
21
+ except FileNotFoundError:
22
+ print(f"File not found: {file_path}")
23
+
24
+ except Exception as e:
25
+ print(f"Error: {e}")
mail2task/extractor.py ADDED
@@ -0,0 +1,100 @@
1
+ import re
2
+ import dateparser
3
+
4
+
5
+ ACTION_WORDS = [
6
+ "submit",
7
+ "schedule",
8
+ "send",
9
+ "complete",
10
+ "review",
11
+ "update",
12
+ "prepare",
13
+ "finish",
14
+ "call",
15
+ "email",
16
+ "organize",
17
+ "create",
18
+ "fix"
19
+ ]
20
+
21
+
22
+ PRIORITY_KEYWORDS = {
23
+ "high": ["urgent", "asap", "important", "immediately"],
24
+ "medium": ["soon", "priority"],
25
+ "low": ["later", "whenever"]
26
+ }
27
+
28
+
29
+ def clean_text(text: str):
30
+ return re.sub(r"\s+", " ", text).strip()
31
+
32
+
33
+ def detect_priority(text: str):
34
+ text_lower = text.lower()
35
+
36
+ for level, keywords in PRIORITY_KEYWORDS.items():
37
+ for keyword in keywords:
38
+ if keyword in text_lower:
39
+ return level
40
+
41
+ return "normal"
42
+
43
+
44
+ def extract_due_date(text: str):
45
+ date = dateparser.parse(
46
+ text,
47
+ settings={"PREFER_DATES_FROM": "future"}
48
+ )
49
+
50
+ if date:
51
+ return date.isoformat()
52
+
53
+ return None
54
+
55
+
56
+ def is_task_sentence(text: str):
57
+ text_lower = text.lower()
58
+
59
+ return any(word in text_lower for word in ACTION_WORDS)
60
+
61
+
62
+ def extract_tasks(email_text: str):
63
+ lines = email_text.splitlines()
64
+
65
+ tasks = []
66
+ seen_titles = set()
67
+
68
+ for line in lines:
69
+ line = clean_text(line)
70
+
71
+ if not line:
72
+ continue
73
+
74
+ if len(line.split()) < 3:
75
+ continue
76
+
77
+ if not is_task_sentence(line):
78
+ continue
79
+
80
+ title = re.sub(
81
+ r"\b(please|kindly)\b",
82
+ "",
83
+ line,
84
+ flags=re.IGNORECASE
85
+ ).strip()
86
+
87
+ if title.lower() in seen_titles:
88
+ continue
89
+
90
+ seen_titles.add(title.lower())
91
+
92
+ task = {
93
+ "title": title,
94
+ "due_date": extract_due_date(line),
95
+ "priority": detect_priority(line)
96
+ }
97
+
98
+ tasks.append(task)
99
+
100
+ return tasks
mail2task/parser.py ADDED
File without changes
@@ -0,0 +1,105 @@
1
+ Metadata-Version: 2.4
2
+ Name: mail2task
3
+ Version: 0.1.0
4
+ Summary: Extract actionable tasks from emails using Python
5
+ Author: Eby J Kavungal
6
+ Requires-Python: >=3.9
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: dateparser
9
+
10
+ # mail2task
11
+
12
+ Extract actionable tasks from messy emails using Python.
13
+
14
+ ## Features
15
+
16
+ - Extract task-like sentences
17
+ - Detect due dates
18
+ - Detect priority levels
19
+ - Clean JSON output
20
+ - CLI support
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ pip install mail2task
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Usage
33
+
34
+ ### Python
35
+
36
+ ```python
37
+ from mail2task import extract_tasks
38
+
39
+ email = """
40
+ Please submit the compliance report by Friday.
41
+
42
+ Schedule the onboarding meeting tomorrow.
43
+ """
44
+
45
+ tasks = extract_tasks(email)
46
+
47
+ print(tasks)
48
+ ```
49
+
50
+ ---
51
+
52
+ ### CLI
53
+
54
+ Create a text file:
55
+
56
+ ```text
57
+ Please submit the report by Friday.
58
+ Schedule the client call tomorrow.
59
+ ```
60
+
61
+ Run:
62
+
63
+ ```bash
64
+ mail2task sample_email.txt
65
+ ```
66
+
67
+ Output:
68
+
69
+ ```json
70
+ [
71
+ {
72
+ "title": "submit the report by Friday.",
73
+ "due_date": "2026-05-29T00:00:00",
74
+ "priority": "normal"
75
+ }
76
+ ]
77
+ ```
78
+
79
+ ---
80
+
81
+ ## Example Use Cases
82
+
83
+ - Email automation
84
+ - Productivity apps
85
+ - AI assistants
86
+ - CRM workflows
87
+ - Task management systems
88
+
89
+ ---
90
+
91
+ ## Project Structure
92
+
93
+ ```text
94
+ mail2task/
95
+ ├── src/
96
+ ├── tests/
97
+ ├── README.md
98
+ ├── pyproject.toml
99
+ ```
100
+
101
+ ---
102
+
103
+ ## License
104
+
105
+ MIT License
@@ -0,0 +1,9 @@
1
+ mail2task/__init__.py,sha256=2cfFK7DT48oa9jyWMRvHKY-EmLKY8WMwDdKZUa3K2ic,36
2
+ mail2task/cli.py,sha256=LHphbntchelvB12WnyDETS2JejOnkmc4AlzLFp_qYGQ,525
3
+ mail2task/extractor.py,sha256=DIb7Ovh8cAGXXKHg2XV_9PpBxATpPRscDr234ovM8aw,1892
4
+ mail2task/parser.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ mail2task-0.1.0.dist-info/METADATA,sha256=y4CF4QpTqZOg3EZi6GOGMgkKGC8Ae288vWiYY4WXxqw,1399
6
+ mail2task-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
7
+ mail2task-0.1.0.dist-info/entry_points.txt,sha256=CpFA9n2w2k1_X2cug9DjJMWc1OqhFQ2bSouyCYf7QAg,49
8
+ mail2task-0.1.0.dist-info/top_level.txt,sha256=0aeUtznLFv-fC6dMinhqQeOb6U-60ExXa1sRoJk6SZQ,10
9
+ mail2task-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (82.0.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mail2task = mail2task.cli:main
@@ -0,0 +1 @@
1
+ mail2task