Skip to content

Commit dcdd8d1

Browse files
committed
Effective implicit keep action
1 parent 58ce220 commit dcdd8d1

5 files changed

Lines changed: 29 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
parser.out
55
parsetab.py
66
*.pyc
7+
*.egg-info/

sifter/grammar/command_list.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,7 @@ def evaluate(self, message, state=None):
2222
# isn't required by the standard, but we might as well.
2323
if len(state.actions) > 0 and state.actions[-1][0] == 'stop':
2424
break
25+
if state.actions.implicit_keep:
26+
state.actions.append('keep')
2527
return state.actions
2628

sifter/t/evaluation_3.msg

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Date: Tue, 1 Apr 1997 09:06:31 -0800 (PST)
2+
From: user1@example.org
3+
To: roadrunner@acme.example.com
4+
Subject: I have a present for you
5+
6+
Look, I'm sorry about the whole anvil thing, and I really
7+
didn't mean to try and drop it on you from the top of the
8+
cliff. I want to try to make it up to you. I've got some
9+
great birdseed over here at my place--top of the line
10+
stuff--and if you come by, I'll have it all wrapped up
11+
for you. I'm really sorry for all the problems I've caused
12+
for you over the years, but I know we can work this out.
13+
--
14+
Wile E. Coyote "Super Genius" coyote@desert.example.org

sifter/t/evaluation_3.rules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
require "fileinto";
2+
if header :contains "from" "coyote" {
3+
discard;
4+
} elsif header :contains ["subject"] ["$$$"] {
5+
discard;
6+
}

sifter/t/test_evaluation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ class TestEvaluateRules(unittest.TestCase):
1616
[('redirect', 'postmaster@example.com')]),
1717
("evaluation_2.msg", "evaluation_2.rules",
1818
[]),
19+
("evaluation_3.msg", "evaluation_1.rules",
20+
[('redirect', 'field@example.com')]),
21+
("evaluation_3.msg", "evaluation_2.rules",
22+
[('fileinto', ['INBOX'])]),
23+
("evaluation_3.msg", "evaluation_3.rules",
24+
[('keep', None)]),
1925
)
2026

2127
def setUp(self):

0 commit comments

Comments
 (0)