@@ -55,12 +55,83 @@ def reset(self):
5555 self ._start_time = None
5656
5757
58+ class LineCheck (Check ):
59+ def __init__ (self ):
60+ Check .__init__ (self )
61+ self ._matches = None
62+
63+ def received (self , line ):
64+ if not line :
65+ return
66+
67+ if self ._is_match (line ):
68+ self ._matches = True
69+ elif self ._is_ruled_out (line ):
70+ self ._matches = False
71+
72+ self ._evaluate ()
73+
74+ def m115 (self , name , data ):
75+ # M115 usually means we stop scanning received lines
76+ if self ._matches is None :
77+ self ._matches = False
78+ self ._evaluate ()
79+
80+ def _evaluate (self ):
81+ if self ._matches is None :
82+ return
83+ self ._triggered = self ._matches
84+ self ._active = False
85+
86+ def reset (self ):
87+ Check .reset (self )
88+ self ._matches = None
89+
90+ def _is_match (self , line ):
91+ return False
92+
93+ def _is_ruled_out (self , line ):
94+ return False
95+
96+
97+ class CapCheck (Check ):
98+ CAP = None
99+
100+ def __init__ (self ):
101+ Check .__init__ (self )
102+ self .cap_seen = False
103+
104+ def cap (self , cap , enabled ):
105+ self .cap_seen = True
106+ if cap == self .CAP :
107+ self ._triggered = self ._eval (enabled )
108+ self ._active = False
109+
110+ def received (self , line ):
111+ if self .cap_seen and not line .startswith ("Cap:" ):
112+ # first non cap line after cap report: cap report over, deactivate
113+ self ._active = False
114+
115+ def _eval (self , enabled ):
116+ # trigger when enabled
117+ return enabled
118+
119+
120+ class NegativeCapCheck (CapCheck ):
121+ def _eval (self , enabled ):
122+ # trigger when NOT enabled
123+ return not enabled
124+
58125
59126class AuthorCheck (Check ):
60127 authors = ()
61128
62129 AUTHOR = "| Author: " .lower ()
63130
131+ def m115 (self , name , data ):
132+ # M115 usually means we stop scanning received lines
133+ self ._active = False
134+
64135 def received (self , line ):
65136 if not line :
66137 return
0 commit comments