Merge lp:~stefanor/ibid/whitespace-336286 into lp:~ibid-core/ibid/old-trunk-pack-0.92
- whitespace-336286
- Merge into old-trunk-pack-0.92
Proposed by
Stefano Rivera
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 560 | ||||
Proposed branch: | lp:~stefanor/ibid/whitespace-336286 | ||||
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/whitespace-336286 | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jonathan Hitchcock | Approve | ||
Michael Gorven | Approve | ||
Review via email: mp+4206@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote : | # |
Revision history for this message
Michael Gorven (mgorven) wrote : | # |
Looks fine to me.
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 'attic/dbusjabber.pl' |
2 | --- attic/dbusjabber.pl 2008-12-23 15:23:51 +0000 |
3 | +++ attic/dbusjabber.pl 2009-03-05 16:33:12 +0000 |
4 | @@ -127,3 +127,4 @@ |
5 | print "* $from -> $type [$status]"; |
6 | } |
7 | |
8 | +# vi: set et sta sw=4 ts=4: |
9 | |
10 | === modified file 'attic/ibid-service.py' |
11 | --- attic/ibid-service.py 2008-12-23 15:23:51 +0000 |
12 | +++ attic/ibid-service.py 2009-03-05 16:33:12 +0000 |
13 | @@ -39,3 +39,5 @@ |
14 | mainloop = gobject.MainLoop() |
15 | print "Running Ibid service." |
16 | mainloop.run() |
17 | + |
18 | +# vi: set et sta sw=4 ts=4: |
19 | |
20 | === modified file 'contrib/buildbotibid.py' |
21 | --- contrib/buildbotibid.py 2009-01-29 14:41:50 +0000 |
22 | +++ contrib/buildbotibid.py 2009-03-05 16:33:12 +0000 |
23 | @@ -84,3 +84,5 @@ |
24 | result = Results[results] |
25 | return getPage("%s?branch=%s&revision=%s&person=%s&result=%s" % \ |
26 | (self.url, branch, rev, person, result)) |
27 | + |
28 | +# vi: set et sta sw=4 ts=4: |
29 | |
30 | === modified file 'ibid/plugins/eval.py' |
31 | --- ibid/plugins/eval.py 2009-03-01 23:01:30 +0000 |
32 | +++ ibid/plugins/eval.py 2009-03-05 16:33:12 +0000 |
33 | @@ -1,65 +1,67 @@ |
34 | try: |
35 | - import perl |
36 | + import perl |
37 | except ImportError: |
38 | - pass |
39 | + pass |
40 | |
41 | try: |
42 | - import lua |
43 | + import lua |
44 | except ImportError: |
45 | - pass |
46 | + pass |
47 | |
48 | from ibid.plugins import Processor, match, authorise |
49 | |
50 | help = {'eval': u'Evaluates Python, Perl and Lua code.'} |
51 | |
52 | class Python(Processor): |
53 | - u"""py <code>""" |
54 | - feature = 'eval' |
55 | - |
56 | - permission = u'eval' |
57 | - |
58 | - @match(r'^py(?:thon)?\s+(.+)$') |
59 | - @authorise |
60 | - def eval(self, event, code): |
61 | - try: |
62 | - globals = {} |
63 | - exec('import os', globals) |
64 | - exec('import sys', globals) |
65 | - exec('import re', globals) |
66 | - exec('import time', globals) |
67 | - result = unicode(eval(code, globals, {})) |
68 | - except Exception, e: |
69 | - result = unicode(e) |
70 | - event.addresponse(result) |
71 | + u"""py <code>""" |
72 | + feature = 'eval' |
73 | + |
74 | + permission = u'eval' |
75 | + |
76 | + @match(r'^py(?:thon)?\s+(.+)$') |
77 | + @authorise |
78 | + def eval(self, event, code): |
79 | + try: |
80 | + globals = {} |
81 | + exec('import os', globals) |
82 | + exec('import sys', globals) |
83 | + exec('import re', globals) |
84 | + exec('import time', globals) |
85 | + result = unicode(eval(code, globals, {})) |
86 | + except Exception, e: |
87 | + result = unicode(e) |
88 | + event.addresponse(result) |
89 | |
90 | class Perl(Processor): |
91 | - u"""pl <code>""" |
92 | - feature = 'eval' |
93 | - |
94 | - permission = u'eval' |
95 | - |
96 | - @match(r'^(?:perl|pl)\s+(.+)$') |
97 | - @authorise |
98 | - def eval(self, event, code): |
99 | - try: |
100 | - result = perl.eval(code) |
101 | - except Exception, e: |
102 | - result = e |
103 | - |
104 | - event.addresponse(unicode(result)) |
105 | + u"""pl <code>""" |
106 | + feature = 'eval' |
107 | + |
108 | + permission = u'eval' |
109 | + |
110 | + @match(r'^(?:perl|pl)\s+(.+)$') |
111 | + @authorise |
112 | + def eval(self, event, code): |
113 | + try: |
114 | + result = perl.eval(code) |
115 | + except Exception, e: |
116 | + result = e |
117 | + |
118 | + event.addresponse(unicode(result)) |
119 | |
120 | class Lua(Processor): |
121 | - u"""lua <code>""" |
122 | - feature = 'eval' |
123 | - |
124 | - permission = u'eval' |
125 | - |
126 | - @match(r'^lua\s+(.+)$') |
127 | - @authorise |
128 | - def eval(self, event, code): |
129 | - try: |
130 | - result = lua.eval(code) |
131 | - except Exception, e: |
132 | - result = e |
133 | - |
134 | - event.addresponse(unicode(result)) |
135 | + u"""lua <code>""" |
136 | + feature = 'eval' |
137 | + |
138 | + permission = u'eval' |
139 | + |
140 | + @match(r'^lua\s+(.+)$') |
141 | + @authorise |
142 | + def eval(self, event, code): |
143 | + try: |
144 | + result = lua.eval(code) |
145 | + except Exception, e: |
146 | + result = e |
147 | + |
148 | + event.addresponse(unicode(result)) |
149 | + |
150 | +# vi: set et sta sw=4 ts=4: |
151 | |
152 | === modified file 'ibid/plugins/help.py' |
153 | --- ibid/plugins/help.py 2009-03-01 23:01:30 +0000 |
154 | +++ ibid/plugins/help.py 2009-03-05 16:33:12 +0000 |
155 | @@ -6,49 +6,52 @@ |
156 | help = {'help': u'Provides help and usage information about plugins.'} |
157 | |
158 | class Help(Processor): |
159 | - u"""features |
160 | - help [<feature>] |
161 | - usage <feature>""" |
162 | - feature = 'help' |
163 | - |
164 | - @match(r'^help$') |
165 | - def intro(self, event): |
166 | - event.addresponse(u'Use "features" to get a list of available features. "help <feature>" will give a description of the feature, and "usage <feature>" will describe how to use it.') |
167 | - |
168 | - @match(r'^features$') |
169 | - def features(self, event): |
170 | - features = [] |
171 | - |
172 | - for processor in ibid.processors: |
173 | - module = eval(processor.__module__) |
174 | - if hasattr(module, 'help'): |
175 | - for feature in module.help.keys(): |
176 | - if feature not in features: |
177 | - features.append(feature) |
178 | - |
179 | - event.addresponse(u' '.join(features)) |
180 | - |
181 | - @match(r'^help\s+(.+)$') |
182 | - def help(self, event, feature): |
183 | - feature = feature.lower() |
184 | - |
185 | - for processor in ibid.processors: |
186 | - module = eval(processor.__module__) |
187 | - if hasattr(module, 'help') and feature in module.help: |
188 | - event.addresponse(module.help[feature]) |
189 | - return |
190 | - |
191 | - event.addresponse(u"I can't help you with %s" % feature) |
192 | - |
193 | - @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$') |
194 | - def usage(self, event, feature): |
195 | - feature = feature.lower() |
196 | - |
197 | - for processor in ibid.processors: |
198 | - for name, klass in inspect.getmembers(processor, inspect.isclass): |
199 | - if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__: |
200 | - for line in klass.__doc__.splitlines(): |
201 | - event.addresponse('Usage: %s' % line.strip()) |
202 | - |
203 | - if not event.responses: |
204 | - event.addresponse(u"I don't know how to use %s either" % feature) |
205 | + u"""features |
206 | + help [<feature>] |
207 | + usage <feature>""" |
208 | + feature = 'help' |
209 | + |
210 | + @match(r'^help$') |
211 | + def intro(self, event): |
212 | + event.addresponse(u'Use "features" to get a list of available features. ' |
213 | + u'"help <feature>" will give a description of the feature, and "usage <feature>" will describe how to use it.') |
214 | + |
215 | + @match(r'^features$') |
216 | + def features(self, event): |
217 | + features = [] |
218 | + |
219 | + for processor in ibid.processors: |
220 | + module = eval(processor.__module__) |
221 | + if hasattr(module, 'help'): |
222 | + for feature in module.help.keys(): |
223 | + if feature not in features: |
224 | + features.append(feature) |
225 | + |
226 | + event.addresponse(u' '.join(features)) |
227 | + |
228 | + @match(r'^help\s+(.+)$') |
229 | + def help(self, event, feature): |
230 | + feature = feature.lower() |
231 | + |
232 | + for processor in ibid.processors: |
233 | + module = eval(processor.__module__) |
234 | + if hasattr(module, 'help') and feature in module.help: |
235 | + event.addresponse(module.help[feature]) |
236 | + return |
237 | + |
238 | + event.addresponse(u"I can't help you with %s" % feature) |
239 | + |
240 | + @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$') |
241 | + def usage(self, event, feature): |
242 | + feature = feature.lower() |
243 | + |
244 | + for processor in ibid.processors: |
245 | + for name, klass in inspect.getmembers(processor, inspect.isclass): |
246 | + if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__: |
247 | + for line in klass.__doc__.splitlines(): |
248 | + event.addresponse('Usage: %s' % line.strip()) |
249 | + |
250 | + if not event.responses: |
251 | + event.addresponse(u"I don't know how to use %s either" % feature) |
252 | + |
253 | +# vi: set et sta sw=4 ts=4: |
254 | |
255 | === modified file 'ibid/plugins/http.py' |
256 | --- ibid/plugins/http.py 2009-03-02 09:21:35 +0000 |
257 | +++ ibid/plugins/http.py 2009-03-05 16:33:12 +0000 |
258 | @@ -10,26 +10,27 @@ |
259 | |
260 | help['get'] = u'Retrieves a URL and returns the HTTP status and optionally the HTML title.' |
261 | class HTTP(Processor): |
262 | - u"""(get|head) <url>""" |
263 | - feature = 'get' |
264 | - |
265 | - max_size = IntOption('max_size', 'Only request this many bytes', 500) |
266 | - |
267 | - @match(r'^(get|head)\s+(.+)$') |
268 | - def handler(self, event, action, url): |
269 | - if not url.lower().startswith("http://") and not url.lower().startswith("https://"): |
270 | - url = "http://" + url |
271 | - |
272 | - http = Http() |
273 | - headers={} |
274 | - if action.lower() == 'get': |
275 | - headers['Range'] = 'bytes=0-%s' % self.max_size |
276 | - response, content = http.request(url, action.upper(), headers=headers) |
277 | - reply = u'%s %s' % (response.status, response.reason) |
278 | - |
279 | - if action.lower() == 'get': |
280 | - match = title.search(content) |
281 | - if match: |
282 | - reply = u'%s "%s"' % (reply, match.groups()[0].strip()) |
283 | - |
284 | - event.addresponse(reply) |
285 | + u"""(get|head) <url>""" |
286 | + feature = 'get' |
287 | + |
288 | + max_size = IntOption('max_size', 'Only request this many bytes', 500) |
289 | + |
290 | + @match(r'^(get|head)\s+(.+)$') |
291 | + def handler(self, event, action, url): |
292 | + if not url.lower().startswith("http://") and not url.lower().startswith("https://"): |
293 | + url = "http://" + url |
294 | + |
295 | + http = Http() |
296 | + headers={} |
297 | + if action.lower() == 'get': |
298 | + headers['Range'] = 'bytes=0-%s' % self.max_size |
299 | + response, content = http.request(url, action.upper(), headers=headers) |
300 | + reply = u'%s %s' % (response.status, response.reason) |
301 | + |
302 | + if action.lower() == 'get': |
303 | + match = title.search(content) |
304 | + if match: |
305 | + reply = u'%s "%s"' % (reply, match.groups()[0].strip()) |
306 | + |
307 | + event.addresponse(reply) |
308 | +# vi: set et sta sw=4 ts=4: |
309 | |
310 | === modified file 'ibid/plugins/morse.py' |
311 | --- ibid/plugins/morse.py 2009-03-02 09:21:35 +0000 |
312 | +++ ibid/plugins/morse.py 2009-03-05 16:33:12 +0000 |
313 | @@ -77,3 +77,5 @@ |
314 | event.addresponse(morse2text(message)) |
315 | else: |
316 | event.addresponse(text2morse(message)) |
317 | + |
318 | +# vi: set et sta sw=4 ts=4: |
319 | |
320 | === modified file 'ibid/test/__init__.py' |
321 | --- ibid/test/__init__.py 2009-01-10 15:33:35 +0000 |
322 | +++ ibid/test/__init__.py 2009-03-05 16:33:12 +0000 |
323 | @@ -17,3 +17,5 @@ |
324 | |
325 | def set_config(config): |
326 | ibid.config = FakeConfig(config) |
327 | + |
328 | +# vi: set et sta sw=4 ts=4: |
329 | |
330 | === modified file 'ibid/test/plugins/test_core.py' |
331 | --- ibid/test/plugins/test_core.py 2009-01-10 15:33:35 +0000 |
332 | +++ ibid/test/plugins/test_core.py 2009-03-05 16:33:12 +0000 |
333 | @@ -84,3 +84,5 @@ |
334 | event.message = u'foo%s%s' % suffix |
335 | self.processor.process(event) |
336 | self.assert_addressed(event, False, u'foo%s%s' % suffix) |
337 | + |
338 | +# vi: set et sta sw=4 ts=4: |
339 | |
340 | === modified file 'ibid/utils.py' |
341 | --- ibid/utils.py 2009-03-05 15:04:46 +0000 |
342 | +++ ibid/utils.py 2009-03-05 16:33:12 +0000 |
343 | @@ -9,16 +9,20 @@ |
344 | import ibid |
345 | |
346 | def ago(delta, units=None): |
347 | - parts = [] |
348 | - |
349 | - for unit, value in (('year', delta.days/365), ('month', delta.days/30 % 12), ('day', delta.days % 30), ('hour', delta.seconds/3600), ('minute', delta.seconds/60 % 60), ('second', delta.seconds % 60), ('millisecond', delta.microseconds/1000)): |
350 | - if value > 0 and (unit != 'millisecond' or len(parts) == 0): |
351 | - parts.append('%s %s%s' % (value, unit, value != 1 and 's' or '')) |
352 | - if units and len(parts) >= units: |
353 | - break |
354 | - |
355 | - formatted = ' and '.join(parts) |
356 | - return formatted.replace(' and ', ', ', len(parts)-2) |
357 | + parts = [] |
358 | + |
359 | + for unit, value in ( |
360 | + ('year', delta.days/365), ('month', delta.days/30 % 12), |
361 | + ('day', delta.days % 30), ('hour', delta.seconds/3600), |
362 | + ('minute', delta.seconds/60 % 60), ('second', delta.seconds % 60), |
363 | + ('millisecond', delta.microseconds/1000)): |
364 | + if value > 0 and (unit != 'millisecond' or len(parts) == 0): |
365 | + parts.append('%s %s%s' % (value, unit, value != 1 and 's' or '')) |
366 | + if units and len(parts) >= units: |
367 | + break |
368 | + |
369 | + formatted = ' and '.join(parts) |
370 | + return formatted.replace(' and ', ', ', len(parts)-2) |
371 | |
372 | def substitute_entity(match): |
373 | ent = match.group(2) |
374 | @@ -37,73 +41,75 @@ |
375 | return entity_re.subn(substitute_entity, string)[0] |
376 | |
377 | def cacheable_download(url, cachefile): |
378 | - """Download url to cachefile if it's modified since cachefile. |
379 | - Specify cachefile in the form pluginname/cachefile. |
380 | - Returns complete path to downloaded file.""" |
381 | - |
382 | - # We do allow absolute paths, for people who know what they are doing, |
383 | - # but the common use case should be pluginname/cachefile. |
384 | - if cachefile[0] not in (os.sep, os.altsep): |
385 | - cachedir = ibid.config.plugins['cachedir'] |
386 | - if not cachedir: |
387 | - cachedir = os.path.join(ibid.options['base'], 'cache') |
388 | - elif cachedir[0] == "~": |
389 | - cachedir = os.path.expanduser(cachedir) |
390 | - |
391 | - plugindir = os.path.join(cachedir, os.path.dirname(cachefile)) |
392 | - if not os.path.isdir(plugindir): |
393 | - os.makedirs(plugindir) |
394 | - |
395 | - cachefile = os.path.join(cachedir, cachefile) |
396 | - |
397 | - exists = os.path.isfile(cachefile) |
398 | - |
399 | - req = urllib2.Request(url) |
400 | - |
401 | - if exists: |
402 | - modified = os.path.getmtime(cachefile) |
403 | - modified = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(modified)) |
404 | - req.add_header("If-Modified-Since", modified) |
405 | - |
406 | - try: |
407 | - connection = urllib2.urlopen(req) |
408 | - except urllib2.HTTPError, e: |
409 | - if e.code == 304 and exists: |
410 | - return cachefile |
411 | - else: |
412 | - raise |
413 | - |
414 | - # Download into a temporary file, in case something goes wrong |
415 | - downloadfile = os.path.join(plugindir, ".download." + os.path.basename(cachefile)) |
416 | - outfile = file(downloadfile, "wb") |
417 | - buf = "x" |
418 | - while len(buf) > 0: |
419 | - buf = connection.read(1024) |
420 | - outfile.write(buf) |
421 | - |
422 | - outfile.close() |
423 | - |
424 | - try: |
425 | - os.rename(downloadfile, cachefile) |
426 | - except OSError: |
427 | - # Are we on a system that doesn't support atomic renames? |
428 | - os.remove(cachefile) |
429 | - os.rename(downloadfile, cachefile) |
430 | - |
431 | - return cachefile |
432 | + """Download url to cachefile if it's modified since cachefile. |
433 | + Specify cachefile in the form pluginname/cachefile. |
434 | + Returns complete path to downloaded file.""" |
435 | + |
436 | + # We do allow absolute paths, for people who know what they are doing, |
437 | + # but the common use case should be pluginname/cachefile. |
438 | + if cachefile[0] not in (os.sep, os.altsep): |
439 | + cachedir = ibid.config.plugins['cachedir'] |
440 | + if not cachedir: |
441 | + cachedir = os.path.join(ibid.options['base'], 'cache') |
442 | + elif cachedir[0] == "~": |
443 | + cachedir = os.path.expanduser(cachedir) |
444 | + |
445 | + plugindir = os.path.join(cachedir, os.path.dirname(cachefile)) |
446 | + if not os.path.isdir(plugindir): |
447 | + os.makedirs(plugindir) |
448 | + |
449 | + cachefile = os.path.join(cachedir, cachefile) |
450 | + |
451 | + exists = os.path.isfile(cachefile) |
452 | + |
453 | + req = urllib2.Request(url) |
454 | + |
455 | + if exists: |
456 | + modified = os.path.getmtime(cachefile) |
457 | + modified = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(modified)) |
458 | + req.add_header("If-Modified-Since", modified) |
459 | + |
460 | + try: |
461 | + connection = urllib2.urlopen(req) |
462 | + except urllib2.HTTPError, e: |
463 | + if e.code == 304 and exists: |
464 | + return cachefile |
465 | + else: |
466 | + raise |
467 | + |
468 | + # Download into a temporary file, in case something goes wrong |
469 | + downloadfile = os.path.join(plugindir, ".download." + os.path.basename(cachefile)) |
470 | + outfile = file(downloadfile, "wb") |
471 | + buf = "x" |
472 | + while len(buf) > 0: |
473 | + buf = connection.read(1024) |
474 | + outfile.write(buf) |
475 | + |
476 | + outfile.close() |
477 | + |
478 | + try: |
479 | + os.rename(downloadfile, cachefile) |
480 | + except OSError: |
481 | + # Are we on a system that doesn't support atomic renames? |
482 | + os.remove(cachefile) |
483 | + os.rename(downloadfile, cachefile) |
484 | + |
485 | + return cachefile |
486 | |
487 | def file_in_path(program): |
488 | - path = os.environ.get("PATH", os.defpath).split(os.pathsep) |
489 | - path = [os.path.join(dir, program) for dir in path] |
490 | - path = [True for file in path if os.path.isfile(file)] |
491 | - return bool(path) |
492 | + path = os.environ.get("PATH", os.defpath).split(os.pathsep) |
493 | + path = [os.path.join(dir, program) for dir in path] |
494 | + path = [True for file in path if os.path.isfile(file)] |
495 | + return bool(path) |
496 | |
497 | def unicode_output(output, errors="strict"): |
498 | - try: |
499 | - encoding = os.getenv("LANG").split(".")[1] |
500 | - except: |
501 | - encoding = "ascii" |
502 | - return unicode(output, encoding, errors) |
503 | + try: |
504 | + encoding = os.getenv("LANG").split(".")[1] |
505 | + except: |
506 | + encoding = "ascii" |
507 | + return unicode(output, encoding, errors) |
508 | |
509 | def ibid_version(): |
510 | - return resource_exists(__name__, '.version') and resource_string(__name__, '.version').strip() or None |
511 | + return resource_exists(__name__, '.version') and resource_string(__name__, '.version').strip() or None |
512 | + |
513 | +# vi: set et sta sw=4 ts=4: |
Pretty straight-forward. Affected modules still seem to work fine.