This repository has been archived by the owner on Aug 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmingle.py
52 lines (45 loc) · 1.89 KB
/
mingle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import text
from feed import FeedPoller
import re
class MinglePoller(FeedPoller):
"""
Format changes to Mingle cards
"""
def parse(self, entry):
m = re.search(r'^(.*/([0-9]+))', entry.id)
if not m:
print "bad entry, %s" % (entry.id, )
return None
url = m.group(1)
issue = int(m.group(2))
author = text.abbrevs(entry.author_detail.name)
assignments = []
details = entry.content[0].value
assignment_phrases = [
r'(?P<property>[^,>]+) set to (?P<value>[^,<]+\w)',
r'(?P<property>[^,>]+) changed from (?P<previous_value>[^,<]+) to (?P<value>[^,<]+\w)',
]
for pattern in assignment_phrases:
for m in re.finditer(pattern, details):
normal_form = None
if re.match(r'\d{4}/\d{2}/\d{2}|\(not set\)', m.group('value')):
pass
elif re.match(r'Planning - Sprint', m.group('property')):
n = re.search(r'(Sprint \d+)', m.group('value'))
if n:
normal_form = "->" + n.group(1)
elif 'Deployed' == m.group('value'):
normal_form = "*Deployed*"
else:
normal_form = text.abbrevs(m.group('property')+" : "+m.group('value'))
if normal_form:
assignments.append(normal_form)
summary = '|'.join(assignments)
for m in re.finditer(r'(?P<property>[^:>]+): (?P<value>[^<]+)', details):
if m.group('property') == 'Comment added':
summary = m.group('value')+" "+summary
for m in re.finditer(r'Description changed', details):
summary += " " + m.group(0)
summary = text.strip(summary, truncate=True)
if summary:
return "#%d: (%s) %s -- %s" % (issue, author, summary, url)