Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: verification/base.py

Issue 6049007: Create IVerifierStatus and add IVerifierStatus.ignored(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: fix diff Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # coding=utf8 1 # coding=utf8
2 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Defines base classes for pending change verification classes.""" 5 """Defines base classes for pending change verification classes."""
6 6
7 import model 7 import model
8 8
9 9
10 class DiscardPending(Exception): 10 class DiscardPending(Exception):
(...skipping 26 matching lines...) Expand all
37 if not self.verifications: 37 if not self.verifications:
38 return False 38 return False
39 return all(v.succeeded() for v in self.verifications.itervalues()) 39 return all(v.succeeded() for v in self.verifications.itervalues())
40 40
41 def failed(self): 41 def failed(self):
42 """At least one verification failed.""" 42 """At least one verification failed."""
43 if not self.verifications: 43 if not self.verifications:
44 return False 44 return False
45 return any(v.failed() for v in self.verifications.itervalues()) 45 return any(v.failed() for v in self.verifications.itervalues())
46 46
47 def ignored(self):
48 """This item shouldn't be processed any further.
47 49
48 class SimpleStatus(model.PersistentMixIn): 50 At least one verification step marked it as ignored.
51 """
52 if not self.verifications:
53 return False
54 return any(v.ignored() for v in self.verifications.itervalues())
55
56 def done(self):
57 """Processing on this item is done."""
58 return self.ignored() or self.succeeded() or self.failed()
59
60
61 class IVerifierStatus(model.PersistentMixIn):
62 """Interface for objects in Verified.verifications dictionary."""
63 def succeeded(self):
64 raise NotImplementedError()
65
66 def failed(self):
67 raise NotImplementedError()
68
69 def ignored(self):
70 raise NotImplementedError()
71
72 def done(self):
73 return self.ignored() or self.succeeded() or self.failed()
74
75
76 class SimpleStatus(IVerifierStatus):
49 """Base class to be used for simple true/false verifiers.""" 77 """Base class to be used for simple true/false verifiers."""
50 def __init__(self, state=None): 78 def __init__(self, state=None):
51 super(SimpleStatus, self).__init__() 79 super(SimpleStatus, self).__init__()
52 self.state = state 80 self.state = state
53 81
54 def succeeded(self): 82 def succeeded(self):
55 return self.state is True 83 return self.state is True
56 84
57 def failed(self): 85 def failed(self):
58 return self.state is False 86 return self.state is False
59 87
88 def ignored(self):
89 return False
90
60 91
61 class Verifier(object): 92 class Verifier(object):
62 name = None 93 name = None
63 94
64 def verify(self, pending, revision): 95 def verify(self, pending, revision):
65 raise NotImplementedError() 96 raise NotImplementedError()
66 97
67 def update_status(self, queue): 98 def update_status(self, queue):
68 raise NotImplementedError() 99 raise NotImplementedError()
69 100
70 def loop(self, queue, gen_obj): 101 def loop(self, queue, gen_obj):
71 """Loops in a pending queue and returns the verified item corresponding to 102 """Loops in a pending queue and returns the verified item corresponding to
72 the Verifier. 103 the Verifier.
73 """ 104 """
74 for pending in queue: 105 for pending in queue:
75 if not pending.verifications.get(self.name, None): 106 if not pending.verifications.get(self.name, None):
76 pending.verifications[self.name] = gen_obj() 107 pending.verifications[self.name] = gen_obj()
77 yield pending, pending.verifications[self.name] 108 yield pending, pending.verifications[self.name]
OLDNEW
« pending_manager.py ('K') | « pending_manager.py ('k') | verification/try_server.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698