annotate commitwatcher/event.py @ 45:32cf3d3469c3 default tip

assert
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 07 Nov 2013 14:19:06 -0800
parents 97dfcdeb9a4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 """
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 event system for watching commits
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
40
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
5 __all__ = ['EventHandler', 'PathEventHandler']
34
463dc92867df commitwatcher/event.py
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
6
33
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7 class EventHandler(object):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 """ABC for events"""
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9
40
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
10 def __init__(self, *notifiers):
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
11 self.notifiers = list(notifiers)
Jeff Hammel <jhammel@mozilla.com>
parents: 37
diff changeset
12
34
463dc92867df commitwatcher/event.py
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
13 def match(self, commit):
463dc92867df commitwatcher/event.py
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
14 """does this event trigger the handler?"""
463dc92867df commitwatcher/event.py
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
15 return True # abstractmethod
463dc92867df commitwatcher/event.py
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
16
33
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17 class PathEventHandler(EventHandler):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 """events based on paths"""
34
463dc92867df commitwatcher/event.py
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
19
463dc92867df commitwatcher/event.py
Jeff Hammel <jhammel@mozilla.com>
parents: 33
diff changeset
20 def match(self, commit):
37
Jeff Hammel <jhammel@mozilla.com>
parents: 34
diff changeset
21 pass # TODO: move path handling -> commit object