Merge lp:~stefanor/ibid/factoid-383388 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Superseded
Proposed branch: lp:~stefanor/ibid/factoid-383388
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/factoid-383388
Reviewer Review Type Date Requested Status
Ibid Core Team Pending
Review via email: mp+7733@code.launchpad.net

This proposal supersedes a proposal from 2009-06-20.

This proposal has been superseded by a proposal from 2009-06-21.

To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

Resubmitted, with stripping only on factoids, not on factoid values.

lp:~stefanor/ibid/factoid-383388 updated
671. By Stefano Rivera

Reverted a mistake I made, cleaning up the get regex. Tidied whitespace.

672. By Stefano Rivera

Don't set factoids with the name '<interrogative> <verb>'

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/factoid.py'
2--- ibid/plugins/factoid.py 2009-06-17 11:58:36 +0000
3+++ ibid/plugins/factoid.py 2009-06-21 14:14:48 +0000
4@@ -17,6 +17,9 @@
5
6 log = logging.getLogger('plugins.factoid')
7
8+def strip_name(unstripped):
9+ return re.match(r'^\s*(.*?)[?!.]*\s*$', unstripped, re.DOTALL).group(1)
10+
11 class FactoidName(Base):
12 __table__ = Table('factoid_names', Base.metadata,
13 Column('id', Integer, primary_key=True),
14@@ -236,6 +239,8 @@
15 @authorise
16 def alias(self, event, target, source):
17
18+ target = strip_name(target)
19+
20 if target.lower() == source.lower():
21 event.addresponse(u"That makes no sense, they *are* the same")
22 return
23@@ -263,7 +268,8 @@
24
25 regex_re = re.compile(r'^/(.*)/(r?)$')
26
27- @match(r'^search\s+(?:for\s+)?(?:(\d+)\s+)?(?:(facts?|values?)\s+)?(?:containing\s+)?(.+?)(?:\s+from\s+)?(\d+)?$')
28+ @match(r'^search\s+(?:for\s+)?(?:(\d+)\s+)?(?:(facts?|values?)\s+)?(?:containing\s+)?(.+?)(?:\s+from\s+)?(\d+)?$',
29+ version='deaddressed')
30 def search(self, event, limit, search_type, pattern, start):
31 limit = limit and min(int(limit), self.limit) or self.default
32 start = start and int(start) or 0
33@@ -321,10 +327,10 @@
34 RPC.__init__(self)
35
36 def setup(self):
37- self.get.im_func.pattern = re.compile(r'^(?:(?:%s)\s+(?:(%s)\s+)?)?(.+?)(?:\s+#(\d+))?(?:\s+/(.+?)/(r?))?$' % ('|'.join(self.interrogatives), '|'.join(self.verbs)), re.I)
38+ self.get.im_func.pattern = re.compile(r'^(?:(?:%s)\s+(?:%s\s+)?)?(.+?)(?:\s+#(\d+))?(?:\s+/(.+?)/(r?))?$' % ('|'.join(self.interrogatives), '|'.join(self.verbs)), re.I)
39
40 @handler
41- def get(self, event, verb, name, number, pattern, is_regex):
42+ def get(self, event, name, number, pattern, is_regex):
43 response = self.remote_get(name, number, pattern, is_regex, event)
44 if response:
45 event.addresponse(response)
46@@ -381,12 +387,15 @@
47 self.set_factoid.im_func.pattern = re.compile(
48 r'^(no[,.: ]\s*)?(.+?)\s+(?:=(\S+)=)?(?(3)|(%s))(\s+also)?\s+((?(3).+|(?!.*=\S+=).+))$'
49 % '|'.join(self.verbs), re.I)
50+ self.set_factoid.im_func.message_version = 'deaddressed'
51
52 @handler
53 @authorise
54 def set_factoid(self, event, correction, name, verb1, verb2, addition, value):
55 verb = verb1 and verb1 or verb2
56
57+ name = strip_name(name)
58+
59 factoid = event.session.query(Factoid).join(Factoid.names)\
60 .filter(func.lower(FactoidName.name)==escape_name(name).lower()).first()
61 if factoid:
62@@ -427,9 +436,10 @@
63 permissions = (u'factoidadmin',)
64 priority = 890
65
66- @match(r'^(.+?)(?:\s+#(\d+)|\s+/(.+?)/(r?))?\s*\+=\s?(.+)$')
67+ @match(r'^(.+?)(?:\s+#(\d+)|\s+/(.+?)/(r?))?\s*\+=(.+)$', version='deaddressed')
68 @authorise
69 def append(self, event, name, number, pattern, is_regex, suffix):
70+ name = strip_name(name)
71 factoids = get_factoid(event.session, name, number, pattern, is_regex, all=True)
72 if len(factoids) == 0:
73 if pattern:

Subscribers

People subscribed via source and target branches