This repository was archived by the owner on Feb 25, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.py
More file actions
84 lines (59 loc) · 2.4 KB
/
Copy pathaction.py
File metadata and controls
84 lines (59 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from .rules import Rules
from enum import Enum
class Action(Rules):
def __init__(self, action: str, value: str = None) -> None:
self._action = action
self._value = value
def rules(self) -> list[str]:
rules = [self.rulestr(action=self._action)]
if self._value != None:
rules.append(self.rulestr(actionValue=self._value))
return rules
class Priority(Enum):
HIGHEST = "Highest"
HIGH = "High"
NORMAL = "Normal"
LOW = "Low"
LOWEST = "Lowest"
class Tag(Enum):
REVIEW = "review"
UPDATE = "update"
IMPORTANT = "important"
class JunkScore(Enum):
JUNK = 1
NOT_JUNK = 0
class ActionFunction:
@staticmethod
def action(action: str):
return lambda: Action(action)
@staticmethod
def actionwithvalue(action: str):
return lambda v: Action(action, v)
@staticmethod
def actionwithpriority(action: str):
def f(priority: Priority):
return Action(action, priority.value)
return f
def actionwithtag(action: str):
def f(tag: Tag):
return Action(action, tag.value)
return f
@staticmethod
def actionwithjunkscore(action: str):
def f(junkscore: JunkScore):
return Action(action, junkscore.value)
return f
class ActionBuilder:
movetofolder = ActionFunction.actionwithvalue("Move to folder") # Move Message To
copytofolder = ActionFunction.actionwithvalue("Copy to folder") # Copy Message to
forward = ActionFunction.actionwithvalue("Forward") # Forward Message to
markread = ActionFunction.action("Mark read") # Mark As Read
markunread = ActionFunction.action("Mark unread") # Mark As Unread
markflagged = ActionFunction.action("Mark flagged") # Add Star
changepriority = ActionFunction.actionwithpriority("Change priority") # Set Priority to (options: Highest, High, Normal, Low, Lowest)
addtag = ActionFunction.actionwithtag("AddTag") # Tag Message
junkscore = ActionFunction.actionwithjunkscore("JunkScore") # Set Junk Status to (options: 0 (Not Junk), 1 (Junk))
ignorethread = ActionFunction.action("Ignore thread") # Ignore Thread
ignoresubthread = ActionFunction.action("Ignore subthread") # Ignore Subthread
watchthread = ActionFunction.action("Watch thread") # Watch Thread
stopexecution = ActionFunction.action("Stop execution") # Stop Filter Execution