Merge lp:~stefanor/ibid/whitespace-336286 into lp:~ibid-core/ibid/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
Reviewer Review Type Date Requested Status
Jonathan Hitchcock Approve
Michael Gorven Approve
Review via email: mp+4206@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

Pretty straight-forward. Affected modules still seem to work fine.

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
=== modified file 'attic/dbusjabber.pl'
--- attic/dbusjabber.pl 2008-12-23 15:23:51 +0000
+++ attic/dbusjabber.pl 2009-03-05 16:33:12 +0000
@@ -127,3 +127,4 @@
127 print "* $from -> $type [$status]";127 print "* $from -> $type [$status]";
128}128}
129129
130# vi: set et sta sw=4 ts=4:
130131
=== modified file 'attic/ibid-service.py'
--- attic/ibid-service.py 2008-12-23 15:23:51 +0000
+++ attic/ibid-service.py 2009-03-05 16:33:12 +0000
@@ -39,3 +39,5 @@
39 mainloop = gobject.MainLoop()39 mainloop = gobject.MainLoop()
40 print "Running Ibid service."40 print "Running Ibid service."
41 mainloop.run()41 mainloop.run()
42
43# vi: set et sta sw=4 ts=4:
4244
=== modified file 'contrib/buildbotibid.py'
--- contrib/buildbotibid.py 2009-01-29 14:41:50 +0000
+++ contrib/buildbotibid.py 2009-03-05 16:33:12 +0000
@@ -84,3 +84,5 @@
84 result = Results[results]84 result = Results[results]
85 return getPage("%s?branch=%s&revision=%s&person=%s&result=%s" % \85 return getPage("%s?branch=%s&revision=%s&person=%s&result=%s" % \
86 (self.url, branch, rev, person, result))86 (self.url, branch, rev, person, result))
87
88# vi: set et sta sw=4 ts=4:
8789
=== modified file 'ibid/plugins/eval.py'
--- ibid/plugins/eval.py 2009-03-01 23:01:30 +0000
+++ ibid/plugins/eval.py 2009-03-05 16:33:12 +0000
@@ -1,65 +1,67 @@
1try:1try:
2 import perl2 import perl
3except ImportError:3except ImportError:
4 pass4 pass
55
6try:6try:
7 import lua7 import lua
8except ImportError:8except ImportError:
9 pass9 pass
1010
11from ibid.plugins import Processor, match, authorise11from ibid.plugins import Processor, match, authorise
1212
13help = {'eval': u'Evaluates Python, Perl and Lua code.'}13help = {'eval': u'Evaluates Python, Perl and Lua code.'}
1414
15class Python(Processor):15class Python(Processor):
16 u"""py <code>"""16 u"""py <code>"""
17 feature = 'eval'17 feature = 'eval'
1818
19 permission = u'eval'19 permission = u'eval'
2020
21 @match(r'^py(?:thon)?\s+(.+)$')21 @match(r'^py(?:thon)?\s+(.+)$')
22 @authorise22 @authorise
23 def eval(self, event, code):23 def eval(self, event, code):
24 try:24 try:
25 globals = {}25 globals = {}
26 exec('import os', globals)26 exec('import os', globals)
27 exec('import sys', globals)27 exec('import sys', globals)
28 exec('import re', globals)28 exec('import re', globals)
29 exec('import time', globals)29 exec('import time', globals)
30 result = unicode(eval(code, globals, {}))30 result = unicode(eval(code, globals, {}))
31 except Exception, e:31 except Exception, e:
32 result = unicode(e)32 result = unicode(e)
33 event.addresponse(result)33 event.addresponse(result)
3434
35class Perl(Processor):35class Perl(Processor):
36 u"""pl <code>"""36 u"""pl <code>"""
37 feature = 'eval'37 feature = 'eval'
3838
39 permission = u'eval'39 permission = u'eval'
4040
41 @match(r'^(?:perl|pl)\s+(.+)$')41 @match(r'^(?:perl|pl)\s+(.+)$')
42 @authorise42 @authorise
43 def eval(self, event, code):43 def eval(self, event, code):
44 try:44 try:
45 result = perl.eval(code)45 result = perl.eval(code)
46 except Exception, e:46 except Exception, e:
47 result = e47 result = e
4848
49 event.addresponse(unicode(result))49 event.addresponse(unicode(result))
5050
51class Lua(Processor):51class Lua(Processor):
52 u"""lua <code>"""52 u"""lua <code>"""
53 feature = 'eval'53 feature = 'eval'
5454
55 permission = u'eval'55 permission = u'eval'
5656
57 @match(r'^lua\s+(.+)$')57 @match(r'^lua\s+(.+)$')
58 @authorise58 @authorise
59 def eval(self, event, code):59 def eval(self, event, code):
60 try:60 try:
61 result = lua.eval(code)61 result = lua.eval(code)
62 except Exception, e:62 except Exception, e:
63 result = e63 result = e
6464
65 event.addresponse(unicode(result))65 event.addresponse(unicode(result))
66
67# vi: set et sta sw=4 ts=4:
6668
=== modified file 'ibid/plugins/help.py'
--- ibid/plugins/help.py 2009-03-01 23:01:30 +0000
+++ ibid/plugins/help.py 2009-03-05 16:33:12 +0000
@@ -6,49 +6,52 @@
6help = {'help': u'Provides help and usage information about plugins.'}6help = {'help': u'Provides help and usage information about plugins.'}
77
8class Help(Processor):8class Help(Processor):
9 u"""features9 u"""features
10 help [<feature>]10 help [<feature>]
11 usage <feature>"""11 usage <feature>"""
12 feature = 'help'12 feature = 'help'
1313
14 @match(r'^help$')14 @match(r'^help$')
15 def intro(self, event):15 def intro(self, event):
16 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.')16 event.addresponse(u'Use "features" to get a list of available features. '
1717 u'"help <feature>" will give a description of the feature, and "usage <feature>" will describe how to use it.')
18 @match(r'^features$')18
19 def features(self, event):19 @match(r'^features$')
20 features = []20 def features(self, event):
2121 features = []
22 for processor in ibid.processors:22
23 module = eval(processor.__module__)23 for processor in ibid.processors:
24 if hasattr(module, 'help'):24 module = eval(processor.__module__)
25 for feature in module.help.keys():25 if hasattr(module, 'help'):
26 if feature not in features:26 for feature in module.help.keys():
27 features.append(feature)27 if feature not in features:
2828 features.append(feature)
29 event.addresponse(u' '.join(features))29
3030 event.addresponse(u' '.join(features))
31 @match(r'^help\s+(.+)$')31
32 def help(self, event, feature):32 @match(r'^help\s+(.+)$')
33 feature = feature.lower()33 def help(self, event, feature):
3434 feature = feature.lower()
35 for processor in ibid.processors:35
36 module = eval(processor.__module__)36 for processor in ibid.processors:
37 if hasattr(module, 'help') and feature in module.help:37 module = eval(processor.__module__)
38 event.addresponse(module.help[feature])38 if hasattr(module, 'help') and feature in module.help:
39 return39 event.addresponse(module.help[feature])
4040 return
41 event.addresponse(u"I can't help you with %s" % feature)41
4242 event.addresponse(u"I can't help you with %s" % feature)
43 @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$')43
44 def usage(self, event, feature):44 @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$')
45 feature = feature.lower()45 def usage(self, event, feature):
4646 feature = feature.lower()
47 for processor in ibid.processors:47
48 for name, klass in inspect.getmembers(processor, inspect.isclass):48 for processor in ibid.processors:
49 if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__:49 for name, klass in inspect.getmembers(processor, inspect.isclass):
50 for line in klass.__doc__.splitlines():50 if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__:
51 event.addresponse('Usage: %s' % line.strip())51 for line in klass.__doc__.splitlines():
5252 event.addresponse('Usage: %s' % line.strip())
53 if not event.responses:53
54 event.addresponse(u"I don't know how to use %s either" % feature)54 if not event.responses:
55 event.addresponse(u"I don't know how to use %s either" % feature)
56
57# vi: set et sta sw=4 ts=4:
5558
=== modified file 'ibid/plugins/http.py'
--- ibid/plugins/http.py 2009-03-02 09:21:35 +0000
+++ ibid/plugins/http.py 2009-03-05 16:33:12 +0000
@@ -10,26 +10,27 @@
1010
11help['get'] = u'Retrieves a URL and returns the HTTP status and optionally the HTML title.'11help['get'] = u'Retrieves a URL and returns the HTTP status and optionally the HTML title.'
12class HTTP(Processor):12class HTTP(Processor):
13 u"""(get|head) <url>"""13 u"""(get|head) <url>"""
14 feature = 'get'14 feature = 'get'
1515
16 max_size = IntOption('max_size', 'Only request this many bytes', 500)16 max_size = IntOption('max_size', 'Only request this many bytes', 500)
1717
18 @match(r'^(get|head)\s+(.+)$')18 @match(r'^(get|head)\s+(.+)$')
19 def handler(self, event, action, url):19 def handler(self, event, action, url):
20 if not url.lower().startswith("http://") and not url.lower().startswith("https://"):20 if not url.lower().startswith("http://") and not url.lower().startswith("https://"):
21 url = "http://" + url21 url = "http://" + url
2222
23 http = Http()23 http = Http()
24 headers={}24 headers={}
25 if action.lower() == 'get':25 if action.lower() == 'get':
26 headers['Range'] = 'bytes=0-%s' % self.max_size26 headers['Range'] = 'bytes=0-%s' % self.max_size
27 response, content = http.request(url, action.upper(), headers=headers)27 response, content = http.request(url, action.upper(), headers=headers)
28 reply = u'%s %s' % (response.status, response.reason)28 reply = u'%s %s' % (response.status, response.reason)
2929
30 if action.lower() == 'get':30 if action.lower() == 'get':
31 match = title.search(content)31 match = title.search(content)
32 if match:32 if match:
33 reply = u'%s "%s"' % (reply, match.groups()[0].strip())33 reply = u'%s "%s"' % (reply, match.groups()[0].strip())
3434
35 event.addresponse(reply)35 event.addresponse(reply)
36# vi: set et sta sw=4 ts=4:
3637
=== modified file 'ibid/plugins/morse.py'
--- ibid/plugins/morse.py 2009-03-02 09:21:35 +0000
+++ ibid/plugins/morse.py 2009-03-05 16:33:12 +0000
@@ -77,3 +77,5 @@
77 event.addresponse(morse2text(message))77 event.addresponse(morse2text(message))
78 else:78 else:
79 event.addresponse(text2morse(message))79 event.addresponse(text2morse(message))
80
81# vi: set et sta sw=4 ts=4:
8082
=== modified file 'ibid/test/__init__.py'
--- ibid/test/__init__.py 2009-01-10 15:33:35 +0000
+++ ibid/test/__init__.py 2009-03-05 16:33:12 +0000
@@ -17,3 +17,5 @@
1717
18def set_config(config):18def set_config(config):
19 ibid.config = FakeConfig(config)19 ibid.config = FakeConfig(config)
20
21# vi: set et sta sw=4 ts=4:
2022
=== modified file 'ibid/test/plugins/test_core.py'
--- ibid/test/plugins/test_core.py 2009-01-10 15:33:35 +0000
+++ ibid/test/plugins/test_core.py 2009-03-05 16:33:12 +0000
@@ -84,3 +84,5 @@
84 event.message = u'foo%s%s' % suffix84 event.message = u'foo%s%s' % suffix
85 self.processor.process(event)85 self.processor.process(event)
86 self.assert_addressed(event, False, u'foo%s%s' % suffix)86 self.assert_addressed(event, False, u'foo%s%s' % suffix)
87
88# vi: set et sta sw=4 ts=4:
8789
=== modified file 'ibid/utils.py'
--- ibid/utils.py 2009-03-05 15:04:46 +0000
+++ ibid/utils.py 2009-03-05 16:33:12 +0000
@@ -9,16 +9,20 @@
9import ibid9import ibid
1010
11def ago(delta, units=None):11def ago(delta, units=None):
12 parts = []12 parts = []
1313
14 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)):14 for unit, value in (
15 if value > 0 and (unit != 'millisecond' or len(parts) == 0):15 ('year', delta.days/365), ('month', delta.days/30 % 12),
16 parts.append('%s %s%s' % (value, unit, value != 1 and 's' or ''))16 ('day', delta.days % 30), ('hour', delta.seconds/3600),
17 if units and len(parts) >= units:17 ('minute', delta.seconds/60 % 60), ('second', delta.seconds % 60),
18 break18 ('millisecond', delta.microseconds/1000)):
1919 if value > 0 and (unit != 'millisecond' or len(parts) == 0):
20 formatted = ' and '.join(parts)20 parts.append('%s %s%s' % (value, unit, value != 1 and 's' or ''))
21 return formatted.replace(' and ', ', ', len(parts)-2)21 if units and len(parts) >= units:
22 break
23
24 formatted = ' and '.join(parts)
25 return formatted.replace(' and ', ', ', len(parts)-2)
2226
23def substitute_entity(match):27def substitute_entity(match):
24 ent = match.group(2)28 ent = match.group(2)
@@ -37,73 +41,75 @@
37 return entity_re.subn(substitute_entity, string)[0]41 return entity_re.subn(substitute_entity, string)[0]
3842
39def cacheable_download(url, cachefile):43def cacheable_download(url, cachefile):
40 """Download url to cachefile if it's modified since cachefile.44 """Download url to cachefile if it's modified since cachefile.
41 Specify cachefile in the form pluginname/cachefile.45 Specify cachefile in the form pluginname/cachefile.
42 Returns complete path to downloaded file."""46 Returns complete path to downloaded file."""
4347
44 # We do allow absolute paths, for people who know what they are doing,48 # We do allow absolute paths, for people who know what they are doing,
45 # but the common use case should be pluginname/cachefile.49 # but the common use case should be pluginname/cachefile.
46 if cachefile[0] not in (os.sep, os.altsep):50 if cachefile[0] not in (os.sep, os.altsep):
47 cachedir = ibid.config.plugins['cachedir']51 cachedir = ibid.config.plugins['cachedir']
48 if not cachedir:52 if not cachedir:
49 cachedir = os.path.join(ibid.options['base'], 'cache')53 cachedir = os.path.join(ibid.options['base'], 'cache')
50 elif cachedir[0] == "~":54 elif cachedir[0] == "~":
51 cachedir = os.path.expanduser(cachedir)55 cachedir = os.path.expanduser(cachedir)
5256
53 plugindir = os.path.join(cachedir, os.path.dirname(cachefile))57 plugindir = os.path.join(cachedir, os.path.dirname(cachefile))
54 if not os.path.isdir(plugindir):58 if not os.path.isdir(plugindir):
55 os.makedirs(plugindir)59 os.makedirs(plugindir)
56 60
57 cachefile = os.path.join(cachedir, cachefile)61 cachefile = os.path.join(cachedir, cachefile)
5862
59 exists = os.path.isfile(cachefile)63 exists = os.path.isfile(cachefile)
6064
61 req = urllib2.Request(url)65 req = urllib2.Request(url)
6266
63 if exists:67 if exists:
64 modified = os.path.getmtime(cachefile)68 modified = os.path.getmtime(cachefile)
65 modified = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(modified))69 modified = time.strftime("%a, %d %b %Y %H:%M:%S GMT", time.gmtime(modified))
66 req.add_header("If-Modified-Since", modified)70 req.add_header("If-Modified-Since", modified)
6771
68 try:72 try:
69 connection = urllib2.urlopen(req)73 connection = urllib2.urlopen(req)
70 except urllib2.HTTPError, e:74 except urllib2.HTTPError, e:
71 if e.code == 304 and exists:75 if e.code == 304 and exists:
72 return cachefile76 return cachefile
73 else:77 else:
74 raise78 raise
75 79
76 # Download into a temporary file, in case something goes wrong80 # Download into a temporary file, in case something goes wrong
77 downloadfile = os.path.join(plugindir, ".download." + os.path.basename(cachefile))81 downloadfile = os.path.join(plugindir, ".download." + os.path.basename(cachefile))
78 outfile = file(downloadfile, "wb")82 outfile = file(downloadfile, "wb")
79 buf = "x"83 buf = "x"
80 while len(buf) > 0:84 while len(buf) > 0:
81 buf = connection.read(1024)85 buf = connection.read(1024)
82 outfile.write(buf)86 outfile.write(buf)
83 87
84 outfile.close()88 outfile.close()
8589
86 try:90 try:
87 os.rename(downloadfile, cachefile)91 os.rename(downloadfile, cachefile)
88 except OSError:92 except OSError:
89 # Are we on a system that doesn't support atomic renames?93 # Are we on a system that doesn't support atomic renames?
90 os.remove(cachefile)94 os.remove(cachefile)
91 os.rename(downloadfile, cachefile)95 os.rename(downloadfile, cachefile)
92 96
93 return cachefile97 return cachefile
9498
95def file_in_path(program):99def file_in_path(program):
96 path = os.environ.get("PATH", os.defpath).split(os.pathsep)100 path = os.environ.get("PATH", os.defpath).split(os.pathsep)
97 path = [os.path.join(dir, program) for dir in path]101 path = [os.path.join(dir, program) for dir in path]
98 path = [True for file in path if os.path.isfile(file)]102 path = [True for file in path if os.path.isfile(file)]
99 return bool(path)103 return bool(path)
100104
101def unicode_output(output, errors="strict"):105def unicode_output(output, errors="strict"):
102 try:106 try:
103 encoding = os.getenv("LANG").split(".")[1]107 encoding = os.getenv("LANG").split(".")[1]
104 except:108 except:
105 encoding = "ascii"109 encoding = "ascii"
106 return unicode(output, encoding, errors)110 return unicode(output, encoding, errors)
107111
108def ibid_version():112def ibid_version():
109 return resource_exists(__name__, '.version') and resource_string(__name__, '.version').strip() or None113 return resource_exists(__name__, '.version') and resource_string(__name__, '.version').strip() or None
114
115# vi: set et sta sw=4 ts=4:

Subscribers

People subscribed via source and target branches