writers.py - more properly detect nicknames in lines
Ignore-this: 3c2adc52abbece612f594d18cc83862c - This patch makes "Action items, per person" search for nicks limited to full words. For example, the nick 'jon' will no longer be assigned lines containing 'jonathan'. - Includes a unit test darcs-hash:20101227075058-82ea9-2b37054e5fed11f6c46a239a4a669efd1293cb5c.gz
This commit is contained in:
parent
7816aa1d45
commit
0ade14ad3a
@ -69,6 +69,8 @@ def replaceWRAP(item):
|
||||
return TextWrapper(width=72, break_long_words=False).fill(m.group(1))
|
||||
return re_wrap.sub(repl, item)
|
||||
|
||||
def makeNickRE(nick):
|
||||
return re.compile('\\b'+re.escape(nick)+'\\b', re.IGNORECASE)
|
||||
|
||||
def MeetBotVersion():
|
||||
import meeting
|
||||
@ -125,14 +127,15 @@ class _BaseWriter(object):
|
||||
|
||||
def iterActionItemsNick(self):
|
||||
for nick in sorted(self.M.attendees.keys(), key=lambda x: x.lower()):
|
||||
def nickitems():
|
||||
nick_re = makeNickRE(nick)
|
||||
def nickitems(nick_re):
|
||||
for m in self.M.minutes:
|
||||
# The hack below is needed because of pickling problems
|
||||
if m.itemtype != "ACTION": continue
|
||||
if m.line.find(nick) == -1: continue
|
||||
if nick_re.search(m.line) is None: continue
|
||||
m.assigned = True
|
||||
yield m
|
||||
yield nick, nickitems()
|
||||
yield nick, nickitems(nick_re=nick_re)
|
||||
def iterActionItemsUnassigned(self):
|
||||
for m in self.M.minutes:
|
||||
if m.itemtype != "ACTION": continue
|
||||
@ -848,11 +851,12 @@ class ReST(_BaseWriter):
|
||||
# Action Items, by person (This could be made lots more efficient)
|
||||
ActionItemsPerson = [ ]
|
||||
for nick in sorted(M.attendees.keys(), key=lambda x: x.lower()):
|
||||
nick_re = makeNickRE(nick)
|
||||
headerPrinted = False
|
||||
for m in M.minutes:
|
||||
# The hack below is needed because of pickling problems
|
||||
if m.itemtype != "ACTION": continue
|
||||
if m.line.find(nick) == -1: continue
|
||||
if nick_re.search(m.line) is None: continue
|
||||
if not headerPrinted:
|
||||
ActionItemsPerson.append("* %s"%rst(nick))
|
||||
headerPrinted = True
|
||||
@ -953,11 +957,12 @@ class Text(_BaseWriter):
|
||||
ActionItemsPerson.append(self.heading('Action items, by person'))
|
||||
numberAssigned = 0
|
||||
for nick in sorted(M.attendees.keys(), key=lambda x: x.lower()):
|
||||
nick_re = makeNickRE(nick)
|
||||
headerPrinted = False
|
||||
for m in M.minutes:
|
||||
# The hack below is needed because of pickling problems
|
||||
if m.itemtype != "ACTION": continue
|
||||
if m.line.find(nick) == -1: continue
|
||||
if nick_re.search(m.line) is None: continue
|
||||
if not headerPrinted:
|
||||
ActionItemsPerson.append("* %s"%text(nick))
|
||||
headerPrinted = True
|
||||
@ -1080,11 +1085,12 @@ class MediaWiki(_BaseWriter):
|
||||
ActionItemsPerson.append(self.heading('Action items, by person'))
|
||||
numberAssigned = 0
|
||||
for nick in sorted(M.attendees.keys(), key=lambda x: x.lower()):
|
||||
nick_re = makeNickRE(nick)
|
||||
headerPrinted = False
|
||||
for m in M.minutes:
|
||||
# The hack below is needed because of pickling problems
|
||||
if m.itemtype != "ACTION": continue
|
||||
if m.line.find(nick) == -1: continue
|
||||
if nick_re.search(m.line) is None: continue
|
||||
if not headerPrinted:
|
||||
ActionItemsPerson.append("* %s"%mw(nick))
|
||||
headerPrinted = True
|
||||
|
@ -81,6 +81,23 @@ class MeetBotTest(unittest.TestCase):
|
||||
# process_meeting(contents=file('test-script-3.log.txt').read(),
|
||||
# extraConfig={'writer_map':self.full_writer_map})
|
||||
|
||||
def test_actionNickMatching(self):
|
||||
script = """
|
||||
20:13:50 <x> #startmeeting
|
||||
20:13:50 <somenick>
|
||||
20:13:50 <someone> #action say somenickLONG
|
||||
20:13:50 <someone> #action say the somenicklong
|
||||
20:13:50 <somenick> I should not have an item assisgned to me.
|
||||
20:13:50 <somenicklong> I should have some things assigned to me.
|
||||
20:13:50 <x> #endmeeting
|
||||
"""
|
||||
M = process_meeting(script)
|
||||
results = M.save()['.html']
|
||||
print results
|
||||
assert not re.search(r'\bsomenick\b(?! \()',
|
||||
results, re.IGNORECASE), \
|
||||
"Nick full-word matching failed"
|
||||
|
||||
all_commands_test_contents = """
|
||||
10:10:10 <x> #startmeeting
|
||||
10:10:10 <x> #topic h6k4orkac
|
||||
|
Loading…
x
Reference in New Issue
Block a user