Merge lp:~stefanor/ibid/ibid-plugin-3 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Merged
Approved by: Jonathan Hitchcock
Approved revision: 584
Merged at revision: not available
Proposed branch: lp:~stefanor/ibid/ibid-plugin-3
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/ibid-plugin-3
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+4547@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

How's this?

Revision history for this message
Michael Gorven (mgorven) wrote :

Haven't tested myself, but looks good.
 review approve

review: Approve
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/__init__.py'
2--- ibid/__init__.py 2009-03-02 11:59:56 +0000
3+++ ibid/__init__.py 2009-03-16 20:55:20 +0000
4@@ -11,7 +11,17 @@
5 import ibid.core
6 from ibid.config import FileConfig
7
8-sources = {}
9+class InsensitiveDict(dict):
10+ def __getitem__(self, key):
11+ return dict.__getitem__(self, key.lower())
12+
13+ def __setitem__(self, key, value):
14+ dict.__setitem__(self, key.lower(), value)
15+
16+ def __contains__(self, key):
17+ return dict.__contains__(self, key.lower())
18+
19+sources = InsensitiveDict()
20 config = {}
21 dispatcher = None
22 processors = []
23
24=== modified file 'ibid/auth.py'
25--- ibid/auth.py 2009-02-23 20:29:44 +0000
26+++ ibid/auth.py 2009-03-16 21:00:23 +0000
27@@ -33,7 +33,7 @@
28 return permission.value
29
30 permissions = []
31- permissions.extend(ibid.sources[source.lower()].permissions)
32+ permissions.extend(ibid.sources[source].permissions)
33 if 'permissions' in ibid.config.auth:
34 permissions.extend(ibid.config.auth['permissions'])
35
36@@ -63,7 +63,7 @@
37
38 config = ibid.config.auth
39 methods = []
40- methods.extend(ibid.sources[event.source.lower()].auth)
41+ methods.extend(ibid.sources[event.source].auth)
42 methods.extend(config['methods'])
43
44 if event.sender['connection'] in self.cache:
45@@ -75,8 +75,8 @@
46 del self.cache[event.sender['connection']]
47
48 for method in methods:
49- if hasattr(ibid.sources[event.source.lower()], 'auth_%s' % method):
50- function = getattr(ibid.sources[event.source.lower()], 'auth_%s' % method)
51+ if hasattr(ibid.sources[event.source], 'auth_%s' % method):
52+ function = getattr(ibid.sources[event.source], 'auth_%s' % method)
53 elif hasattr(self, method):
54 function = getattr(self, method)
55 else:
56
57=== modified file 'ibid/core.py'
58--- ibid/core.py 2009-03-16 17:05:45 +0000
59+++ ibid/core.py 2009-03-16 21:00:23 +0000
60@@ -42,7 +42,7 @@
61 return event
62
63 def send(self, response):
64- source = response['source'].lower()
65+ source = response['source']
66 if source in ibid.sources:
67 reactor.callFromThread(ibid.sources[source].send, response)
68 self.log.debug(u"Sent response to non-origin source %s: %s", source, response['reply'])
69@@ -91,8 +91,8 @@
70 self.log.exception(u"Couldn't import %s and instantiate %s", module, factory)
71 return
72
73- ibid.sources[name.lower()] = moduleclass(name)
74- ibid.sources[name.lower()].setServiceParent(service)
75+ ibid.sources[name] = moduleclass(name)
76+ ibid.sources[name].setServiceParent(service)
77 self.log.info(u"Loaded %s source %s", type, name)
78 return True
79
80@@ -102,7 +102,6 @@
81 self.load_source(source, service)
82
83 def unload_source(self, name):
84- name = name.lower()
85 if name not in ibid.sources:
86 return False
87
88
89=== modified file 'ibid/plugins/auth.py'
90--- ibid/plugins/auth.py 2009-03-15 20:16:04 +0000
91+++ ibid/plugins/auth.py 2009-03-16 20:55:20 +0000
92@@ -41,7 +41,10 @@
93 return
94
95 if source:
96- source = ibid.sources[source.lower()].name
97+ if source not in ibid.sources:
98+ event.addresponse(u"I am not connected to %s", source)
99+ return
100+ source = ibid.sources[source].name
101
102 if method.lower() == 'password':
103 password = hash(credential)
104
105=== modified file 'ibid/plugins/bzr.py'
106--- ibid/plugins/bzr.py 2009-03-10 10:34:37 +0000
107+++ ibid/plugins/bzr.py 2009-03-16 20:55:20 +0000
108@@ -114,8 +114,7 @@
109
110 @handler
111 def launchpad(self, event):
112- if event.source.lower() not in ibid.sources \
113- or ibid.sources[event.source.lower()].type != 'smtp' \
114+ if ibid.sources[event.source].type != 'smtp' \
115 or 'X-Launchpad-Branch' not in event.headers:
116 return
117
118
119=== modified file 'ibid/plugins/core.py'
120--- ibid/plugins/core.py 2009-03-10 00:11:55 +0000
121+++ ibid/plugins/core.py 2009-03-16 20:55:20 +0000
122@@ -74,8 +74,7 @@
123 response['target'] = event.channel
124 if 'source' not in response:
125 response['source'] = event.source
126- if 'action' in response and (response['source'].lower() not in ibid.sources \
127- or ibid.sources[response['source'].lower()].type not in ('irc', 'silc')):
128+ if 'action' in response and ibid.sources[response['source']].type not in ('irc', 'silc'):
129 response['reply'] = '* %s %s' % (ibid.config['botname'], response['reply'])
130 converted.append(response)
131
132
133=== modified file 'ibid/plugins/identity.py'
134--- ibid/plugins/identity.py 2009-03-08 13:16:28 +0000
135+++ ibid/plugins/identity.py 2009-03-16 20:55:20 +0000
136@@ -107,10 +107,11 @@
137 event.addresponse(u'This identity is already attached to account %s', ident.account.username)
138 return
139
140- if source.lower() not in ibid.sources:
141+ if source not in ibid.sources:
142 event.addresponse(u'I am not connected to %s', source)
143+ return
144 else:
145- source = ibid.sources[source.lower()].name
146+ source = ibid.sources[source].name
147
148 if not admin:
149 token = ''.join([choice(chars) for i in xrange(16)])
150
151=== modified file 'ibid/plugins/irc.py'
152--- ibid/plugins/irc.py 2009-03-08 13:16:28 +0000
153+++ ibid/plugins/irc.py 2009-03-16 20:55:20 +0000
154@@ -24,11 +24,11 @@
155 return
156 channel = event.channel
157
158- if source.lower() not in ibid.sources:
159- event.addresponse(u"I don't have a source called %s", source.lower())
160+ if source not in ibid.sources:
161+ event.addresponse(u"I am not connected to %s", source)
162 return
163
164- source = ibid.sources[source.lower()]
165+ source = ibid.sources[source]
166
167 if not hasattr(source, 'join'):
168 event.addresponse(u'%s cannot join/part channels', source.name)
169@@ -48,11 +48,11 @@
170 if not source:
171 source = event.source
172
173- if source.lower() not in ibid.sources:
174- event.addresponse(u"I don't have a source called %s", source.lower())
175+ if source not in ibid.sources:
176+ event.addresponse(u"I am not connected to %s", source.lower())
177 return
178
179- source = ibid.sources[source.lower()]
180+ source = ibid.sources[source]
181
182 if not hasattr(source, 'change_nick'):
183 event.addresponse(u'%s cannot change nicks', source)
184
185=== modified file 'ibid/plugins/log.py'
186--- ibid/plugins/log.py 2009-03-16 19:30:55 +0000
187+++ ibid/plugins/log.py 2009-03-16 20:55:20 +0000
188@@ -20,7 +20,7 @@
189
190 def get_logfile(self, source, channel, when):
191 when = localtime(when)
192- if source.lower() in ibid.sources and ibid.sources[source.lower()].type == 'jabber':
193+ if ibid.sources[source].type == 'jabber':
194 channel = channel.split('/')[0]
195 filename = self.log % { 'source': source,
196 'channel': channel,
197
198=== modified file 'ibid/plugins/sources.py'
199--- ibid/plugins/sources.py 2009-03-08 13:16:28 +0000
200+++ ibid/plugins/sources.py 2009-03-16 20:55:20 +0000
201@@ -13,8 +13,9 @@
202 @match(r'^connect\s+(?:to\s+)?(\S+)$')
203 @authorise
204 def connect(self, event, source):
205-
206- if ibid.sources[source.lower()].connect():
207+ if source not in ibid.sources:
208+ event.addresponse(u"I don't have a source called %s", source)
209+ elif ibid.sources[source].connect():
210 event.addresponse(u'Connecting to %s', source)
211 else:
212 event.addresponse(u"I couldn't connect to %s", source)
213@@ -22,8 +23,9 @@
214 @match(r'^disconnect\s+(?:from\s+)?(\S+)$')
215 @authorise
216 def disconnect(self, event, source):
217-
218- if ibid.sources[source.lower()].disconnect():
219+ if source not in ibid.sources:
220+ event.addresponse(u"I am not connected to %s", source)
221+ elif ibid.sources[source].disconnect():
222 event.addresponse(u'Disconnecting from %s', source)
223 else:
224 event.addresponse(u"I couldn't disconnect from %s", source)
225
226=== modified file 'scripts/ibid-plugin'
227--- scripts/ibid-plugin 2009-03-10 00:11:55 +0000
228+++ scripts/ibid-plugin 2009-03-16 20:55:20 +0000
229@@ -44,6 +44,11 @@
230 ibid.reloader.reload_databases()
231 ibid.reloader.reload_dispatcher()
232
233+class TestSource(dict):
234+ type = 'test'
235+
236+ibid.sources[u'test_source'] = TestSource()
237+
238 plugins = set(args)
239 if options.load_all:
240 plugins = set(ibid.config.get("load"))

Subscribers

People subscribed via source and target branches