annotate commitwatcher/agent.py @ 9:08dd6fbbec3a

commitwatcher/agent.py
author Jeff Hammel <jhammel@mozilla.com>
date Fri, 27 Sep 2013 14:23:53 -0700
parents 2061b13f7aad
children 7ae60d2ff1c2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 """
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 agents to gather commits
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3 """
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
5 import feedparser
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
6 from .commit import Commit
6
883c88b13142 commitwatcher/agent.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
7 from .store import MemoryStore
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
8
1
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 class Agent(object):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 """abstract base class"""
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11
6
883c88b13142 commitwatcher/agent.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
12 def __init__(self, repository, store=None):
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
13 """
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
14 repository -- repo to monitor
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
15 """
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
16 self.repository = repository
6
883c88b13142 commitwatcher/agent.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 2
diff changeset
17 self.store = MemoryStore() if store is None else store
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
18
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
19
1
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 class LocalCheckoutAgent(object):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
21 """agent based on local checkouts"""
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
23
1
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 class FeedAgent(Agent):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 """gathers changesets by reading RSS/Atom"""
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
26
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
27 def feed(self):
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
28 """feed URL"""
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
29 return '/'.join((self.repository.rstrip('/'), 'atom-log'))
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
30
9
08dd6fbbec3a commitwatcher/agent.py
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
31 @abstractmethod
08dd6fbbec3a commitwatcher/agent.py
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
32 def files(self, revision):
08dd6fbbec3a commitwatcher/agent.py
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
33 """gets the files from the revision link"""
08dd6fbbec3a commitwatcher/agent.py
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
34
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
35 def update(self):
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
36 """update"""
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
37
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
38 feed = feedparser.parse(self.feed())
8
2061b13f7aad commitwatcher/agent.py
Jeff Hammel <jhammel@mozilla.com>
parents: 7
diff changeset
39 for entry in feed['entries']:
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
40
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
41 # get paths from diff
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
42 link = entry['link']
7
296af1d32b6a commitwatcher/agent.py
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
43 print link
9
08dd6fbbec3a commitwatcher/agent.py
Jeff Hammel <jhammel@mozilla.com>
parents: 8
diff changeset
44 files = self.files(link)
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
45 # TODO
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 1
diff changeset
46
7
296af1d32b6a commitwatcher/agent.py
Jeff Hammel <jhammel@mozilla.com>
parents: 6
diff changeset
47 # TODO commit = Commit()