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 | 127 | print "* $from -> $type [$status]"; | 127 | print "* $from -> $type [$status]"; |
6 | 128 | } | 128 | } |
7 | 129 | 129 | ||
8 | 130 | # vi: set et sta sw=4 ts=4: | ||
9 | 130 | 131 | ||
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 | 39 | mainloop = gobject.MainLoop() | 39 | mainloop = gobject.MainLoop() |
15 | 40 | print "Running Ibid service." | 40 | print "Running Ibid service." |
16 | 41 | mainloop.run() | 41 | mainloop.run() |
17 | 42 | |||
18 | 43 | # vi: set et sta sw=4 ts=4: | ||
19 | 42 | 44 | ||
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 | 84 | result = Results[results] | 84 | result = Results[results] |
25 | 85 | return getPage("%s?branch=%s&revision=%s&person=%s&result=%s" % \ | 85 | return getPage("%s?branch=%s&revision=%s&person=%s&result=%s" % \ |
26 | 86 | (self.url, branch, rev, person, result)) | 86 | (self.url, branch, rev, person, result)) |
27 | 87 | |||
28 | 88 | # vi: set et sta sw=4 ts=4: | ||
29 | 87 | 89 | ||
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 | 1 | try: | 1 | try: |
36 | 2 | import perl | 2 | import perl |
37 | 3 | except ImportError: | 3 | except ImportError: |
39 | 4 | pass | 4 | pass |
40 | 5 | 5 | ||
41 | 6 | try: | 6 | try: |
43 | 7 | import lua | 7 | import lua |
44 | 8 | except ImportError: | 8 | except ImportError: |
46 | 9 | pass | 9 | pass |
47 | 10 | 10 | ||
48 | 11 | from ibid.plugins import Processor, match, authorise | 11 | from ibid.plugins import Processor, match, authorise |
49 | 12 | 12 | ||
50 | 13 | help = {'eval': u'Evaluates Python, Perl and Lua code.'} | 13 | help = {'eval': u'Evaluates Python, Perl and Lua code.'} |
51 | 14 | 14 | ||
52 | 15 | class Python(Processor): | 15 | class Python(Processor): |
71 | 16 | u"""py <code>""" | 16 | u"""py <code>""" |
72 | 17 | feature = 'eval' | 17 | feature = 'eval' |
73 | 18 | 18 | ||
74 | 19 | permission = u'eval' | 19 | permission = u'eval' |
75 | 20 | 20 | ||
76 | 21 | @match(r'^py(?:thon)?\s+(.+)$') | 21 | @match(r'^py(?:thon)?\s+(.+)$') |
77 | 22 | @authorise | 22 | @authorise |
78 | 23 | def eval(self, event, code): | 23 | def eval(self, event, code): |
79 | 24 | try: | 24 | try: |
80 | 25 | globals = {} | 25 | globals = {} |
81 | 26 | exec('import os', globals) | 26 | exec('import os', globals) |
82 | 27 | exec('import sys', globals) | 27 | exec('import sys', globals) |
83 | 28 | exec('import re', globals) | 28 | exec('import re', globals) |
84 | 29 | exec('import time', globals) | 29 | exec('import time', globals) |
85 | 30 | result = unicode(eval(code, globals, {})) | 30 | result = unicode(eval(code, globals, {})) |
86 | 31 | except Exception, e: | 31 | except Exception, e: |
87 | 32 | result = unicode(e) | 32 | result = unicode(e) |
88 | 33 | event.addresponse(result) | 33 | event.addresponse(result) |
89 | 34 | 34 | ||
90 | 35 | class Perl(Processor): | 35 | class Perl(Processor): |
105 | 36 | u"""pl <code>""" | 36 | u"""pl <code>""" |
106 | 37 | feature = 'eval' | 37 | feature = 'eval' |
107 | 38 | 38 | ||
108 | 39 | permission = u'eval' | 39 | permission = u'eval' |
109 | 40 | 40 | ||
110 | 41 | @match(r'^(?:perl|pl)\s+(.+)$') | 41 | @match(r'^(?:perl|pl)\s+(.+)$') |
111 | 42 | @authorise | 42 | @authorise |
112 | 43 | def eval(self, event, code): | 43 | def eval(self, event, code): |
113 | 44 | try: | 44 | try: |
114 | 45 | result = perl.eval(code) | 45 | result = perl.eval(code) |
115 | 46 | except Exception, e: | 46 | except Exception, e: |
116 | 47 | result = e | 47 | result = e |
117 | 48 | 48 | ||
118 | 49 | event.addresponse(unicode(result)) | 49 | event.addresponse(unicode(result)) |
119 | 50 | 50 | ||
120 | 51 | class Lua(Processor): | 51 | class Lua(Processor): |
135 | 52 | u"""lua <code>""" | 52 | u"""lua <code>""" |
136 | 53 | feature = 'eval' | 53 | feature = 'eval' |
137 | 54 | 54 | ||
138 | 55 | permission = u'eval' | 55 | permission = u'eval' |
139 | 56 | 56 | ||
140 | 57 | @match(r'^lua\s+(.+)$') | 57 | @match(r'^lua\s+(.+)$') |
141 | 58 | @authorise | 58 | @authorise |
142 | 59 | def eval(self, event, code): | 59 | def eval(self, event, code): |
143 | 60 | try: | 60 | try: |
144 | 61 | result = lua.eval(code) | 61 | result = lua.eval(code) |
145 | 62 | except Exception, e: | 62 | except Exception, e: |
146 | 63 | result = e | 63 | result = e |
147 | 64 | 64 | ||
148 | 65 | event.addresponse(unicode(result)) | 65 | event.addresponse(unicode(result)) |
149 | 66 | |||
150 | 67 | # vi: set et sta sw=4 ts=4: | ||
151 | 66 | 68 | ||
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 | 6 | help = {'help': u'Provides help and usage information about plugins.'} | 6 | help = {'help': u'Provides help and usage information about plugins.'} |
157 | 7 | 7 | ||
158 | 8 | class Help(Processor): | 8 | class Help(Processor): |
205 | 9 | u"""features | 9 | u"""features |
206 | 10 | help [<feature>] | 10 | help [<feature>] |
207 | 11 | usage <feature>""" | 11 | usage <feature>""" |
208 | 12 | feature = 'help' | 12 | feature = 'help' |
209 | 13 | 13 | ||
210 | 14 | @match(r'^help$') | 14 | @match(r'^help$') |
211 | 15 | def intro(self, event): | 15 | def intro(self, event): |
212 | 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. ' |
213 | 17 | 17 | u'"help <feature>" will give a description of the feature, and "usage <feature>" will describe how to use it.') | |
214 | 18 | @match(r'^features$') | 18 | |
215 | 19 | def features(self, event): | 19 | @match(r'^features$') |
216 | 20 | features = [] | 20 | def features(self, event): |
217 | 21 | 21 | features = [] | |
218 | 22 | for processor in ibid.processors: | 22 | |
219 | 23 | module = eval(processor.__module__) | 23 | for processor in ibid.processors: |
220 | 24 | if hasattr(module, 'help'): | 24 | module = eval(processor.__module__) |
221 | 25 | for feature in module.help.keys(): | 25 | if hasattr(module, 'help'): |
222 | 26 | if feature not in features: | 26 | for feature in module.help.keys(): |
223 | 27 | features.append(feature) | 27 | if feature not in features: |
224 | 28 | 28 | features.append(feature) | |
225 | 29 | event.addresponse(u' '.join(features)) | 29 | |
226 | 30 | 30 | event.addresponse(u' '.join(features)) | |
227 | 31 | @match(r'^help\s+(.+)$') | 31 | |
228 | 32 | def help(self, event, feature): | 32 | @match(r'^help\s+(.+)$') |
229 | 33 | feature = feature.lower() | 33 | def help(self, event, feature): |
230 | 34 | 34 | feature = feature.lower() | |
231 | 35 | for processor in ibid.processors: | 35 | |
232 | 36 | module = eval(processor.__module__) | 36 | for processor in ibid.processors: |
233 | 37 | if hasattr(module, 'help') and feature in module.help: | 37 | module = eval(processor.__module__) |
234 | 38 | event.addresponse(module.help[feature]) | 38 | if hasattr(module, 'help') and feature in module.help: |
235 | 39 | return | 39 | event.addresponse(module.help[feature]) |
236 | 40 | 40 | return | |
237 | 41 | event.addresponse(u"I can't help you with %s" % feature) | 41 | |
238 | 42 | 42 | event.addresponse(u"I can't help you with %s" % feature) | |
239 | 43 | @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$') | 43 | |
240 | 44 | def usage(self, event, feature): | 44 | @match(r'^(?:usage|how\s+do\s+I\s+use)\s+(.+)$') |
241 | 45 | feature = feature.lower() | 45 | def usage(self, event, feature): |
242 | 46 | 46 | feature = feature.lower() | |
243 | 47 | for processor in ibid.processors: | 47 | |
244 | 48 | for name, klass in inspect.getmembers(processor, inspect.isclass): | 48 | for processor in ibid.processors: |
245 | 49 | if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__: | 49 | for name, klass in inspect.getmembers(processor, inspect.isclass): |
246 | 50 | for line in klass.__doc__.splitlines(): | 50 | if hasattr(klass, 'feature') and klass.feature == feature and klass.__doc__: |
247 | 51 | event.addresponse('Usage: %s' % line.strip()) | 51 | for line in klass.__doc__.splitlines(): |
248 | 52 | 52 | event.addresponse('Usage: %s' % line.strip()) | |
249 | 53 | if not event.responses: | 53 | |
250 | 54 | event.addresponse(u"I don't know how to use %s either" % feature) | 54 | if not event.responses: |
251 | 55 | event.addresponse(u"I don't know how to use %s either" % feature) | ||
252 | 56 | |||
253 | 57 | # vi: set et sta sw=4 ts=4: | ||
254 | 55 | 58 | ||
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 | 10 | 10 | ||
260 | 11 | help['get'] = u'Retrieves a URL and returns the HTTP status and optionally the HTML title.' | 11 | help['get'] = u'Retrieves a URL and returns the HTTP status and optionally the HTML title.' |
261 | 12 | class HTTP(Processor): | 12 | class HTTP(Processor): |
285 | 13 | u"""(get|head) <url>""" | 13 | u"""(get|head) <url>""" |
286 | 14 | feature = 'get' | 14 | feature = 'get' |
287 | 15 | 15 | ||
288 | 16 | max_size = IntOption('max_size', 'Only request this many bytes', 500) | 16 | max_size = IntOption('max_size', 'Only request this many bytes', 500) |
289 | 17 | 17 | ||
290 | 18 | @match(r'^(get|head)\s+(.+)$') | 18 | @match(r'^(get|head)\s+(.+)$') |
291 | 19 | def handler(self, event, action, url): | 19 | def handler(self, event, action, url): |
292 | 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://"): |
293 | 21 | url = "http://" + url | 21 | url = "http://" + url |
294 | 22 | 22 | ||
295 | 23 | http = Http() | 23 | http = Http() |
296 | 24 | headers={} | 24 | headers={} |
297 | 25 | if action.lower() == 'get': | 25 | if action.lower() == 'get': |
298 | 26 | headers['Range'] = 'bytes=0-%s' % self.max_size | 26 | headers['Range'] = 'bytes=0-%s' % self.max_size |
299 | 27 | response, content = http.request(url, action.upper(), headers=headers) | 27 | response, content = http.request(url, action.upper(), headers=headers) |
300 | 28 | reply = u'%s %s' % (response.status, response.reason) | 28 | reply = u'%s %s' % (response.status, response.reason) |
301 | 29 | 29 | ||
302 | 30 | if action.lower() == 'get': | 30 | if action.lower() == 'get': |
303 | 31 | match = title.search(content) | 31 | match = title.search(content) |
304 | 32 | if match: | 32 | if match: |
305 | 33 | reply = u'%s "%s"' % (reply, match.groups()[0].strip()) | 33 | reply = u'%s "%s"' % (reply, match.groups()[0].strip()) |
306 | 34 | 34 | ||
307 | 35 | event.addresponse(reply) | 35 | event.addresponse(reply) |
308 | 36 | # vi: set et sta sw=4 ts=4: | ||
309 | 36 | 37 | ||
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 | 77 | event.addresponse(morse2text(message)) | 77 | event.addresponse(morse2text(message)) |
315 | 78 | else: | 78 | else: |
316 | 79 | event.addresponse(text2morse(message)) | 79 | event.addresponse(text2morse(message)) |
317 | 80 | |||
318 | 81 | # vi: set et sta sw=4 ts=4: | ||
319 | 80 | 82 | ||
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 | 17 | 17 | ||
325 | 18 | def set_config(config): | 18 | def set_config(config): |
326 | 19 | ibid.config = FakeConfig(config) | 19 | ibid.config = FakeConfig(config) |
327 | 20 | |||
328 | 21 | # vi: set et sta sw=4 ts=4: | ||
329 | 20 | 22 | ||
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 | 84 | event.message = u'foo%s%s' % suffix | 84 | event.message = u'foo%s%s' % suffix |
335 | 85 | self.processor.process(event) | 85 | self.processor.process(event) |
336 | 86 | self.assert_addressed(event, False, u'foo%s%s' % suffix) | 86 | self.assert_addressed(event, False, u'foo%s%s' % suffix) |
337 | 87 | |||
338 | 88 | # vi: set et sta sw=4 ts=4: | ||
339 | 87 | 89 | ||
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 | 9 | import ibid | 9 | import ibid |
345 | 10 | 10 | ||
346 | 11 | def ago(delta, units=None): | 11 | def ago(delta, units=None): |
357 | 12 | parts = [] | 12 | parts = [] |
358 | 13 | 13 | ||
359 | 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 ( |
360 | 15 | if value > 0 and (unit != 'millisecond' or len(parts) == 0): | 15 | ('year', delta.days/365), ('month', delta.days/30 % 12), |
361 | 16 | parts.append('%s %s%s' % (value, unit, value != 1 and 's' or '')) | 16 | ('day', delta.days % 30), ('hour', delta.seconds/3600), |
362 | 17 | if units and len(parts) >= units: | 17 | ('minute', delta.seconds/60 % 60), ('second', delta.seconds % 60), |
363 | 18 | break | 18 | ('millisecond', delta.microseconds/1000)): |
364 | 19 | 19 | if value > 0 and (unit != 'millisecond' or len(parts) == 0): | |
365 | 20 | formatted = ' and '.join(parts) | 20 | parts.append('%s %s%s' % (value, unit, value != 1 and 's' or '')) |
366 | 21 | return formatted.replace(' and ', ', ', len(parts)-2) | 21 | if units and len(parts) >= units: |
367 | 22 | break | ||
368 | 23 | |||
369 | 24 | formatted = ' and '.join(parts) | ||
370 | 25 | return formatted.replace(' and ', ', ', len(parts)-2) | ||
371 | 22 | 26 | ||
372 | 23 | def substitute_entity(match): | 27 | def substitute_entity(match): |
373 | 24 | ent = match.group(2) | 28 | ent = match.group(2) |
374 | @@ -37,73 +41,75 @@ | |||
375 | 37 | return entity_re.subn(substitute_entity, string)[0] | 41 | return entity_re.subn(substitute_entity, string)[0] |
376 | 38 | 42 | ||
377 | 39 | def cacheable_download(url, cachefile): | 43 | def cacheable_download(url, cachefile): |
432 | 40 | """Download url to cachefile if it's modified since cachefile. | 44 | """Download url to cachefile if it's modified since cachefile. |
433 | 41 | Specify cachefile in the form pluginname/cachefile. | 45 | Specify cachefile in the form pluginname/cachefile. |
434 | 42 | Returns complete path to downloaded file.""" | 46 | Returns complete path to downloaded file.""" |
435 | 43 | 47 | ||
436 | 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, |
437 | 45 | # but the common use case should be pluginname/cachefile. | 49 | # but the common use case should be pluginname/cachefile. |
438 | 46 | if cachefile[0] not in (os.sep, os.altsep): | 50 | if cachefile[0] not in (os.sep, os.altsep): |
439 | 47 | cachedir = ibid.config.plugins['cachedir'] | 51 | cachedir = ibid.config.plugins['cachedir'] |
440 | 48 | if not cachedir: | 52 | if not cachedir: |
441 | 49 | cachedir = os.path.join(ibid.options['base'], 'cache') | 53 | cachedir = os.path.join(ibid.options['base'], 'cache') |
442 | 50 | elif cachedir[0] == "~": | 54 | elif cachedir[0] == "~": |
443 | 51 | cachedir = os.path.expanduser(cachedir) | 55 | cachedir = os.path.expanduser(cachedir) |
444 | 52 | 56 | ||
445 | 53 | plugindir = os.path.join(cachedir, os.path.dirname(cachefile)) | 57 | plugindir = os.path.join(cachedir, os.path.dirname(cachefile)) |
446 | 54 | if not os.path.isdir(plugindir): | 58 | if not os.path.isdir(plugindir): |
447 | 55 | os.makedirs(plugindir) | 59 | os.makedirs(plugindir) |
448 | 56 | 60 | ||
449 | 57 | cachefile = os.path.join(cachedir, cachefile) | 61 | cachefile = os.path.join(cachedir, cachefile) |
450 | 58 | 62 | ||
451 | 59 | exists = os.path.isfile(cachefile) | 63 | exists = os.path.isfile(cachefile) |
452 | 60 | 64 | ||
453 | 61 | req = urllib2.Request(url) | 65 | req = urllib2.Request(url) |
454 | 62 | 66 | ||
455 | 63 | if exists: | 67 | if exists: |
456 | 64 | modified = os.path.getmtime(cachefile) | 68 | modified = os.path.getmtime(cachefile) |
457 | 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)) |
458 | 66 | req.add_header("If-Modified-Since", modified) | 70 | req.add_header("If-Modified-Since", modified) |
459 | 67 | 71 | ||
460 | 68 | try: | 72 | try: |
461 | 69 | connection = urllib2.urlopen(req) | 73 | connection = urllib2.urlopen(req) |
462 | 70 | except urllib2.HTTPError, e: | 74 | except urllib2.HTTPError, e: |
463 | 71 | if e.code == 304 and exists: | 75 | if e.code == 304 and exists: |
464 | 72 | return cachefile | 76 | return cachefile |
465 | 73 | else: | 77 | else: |
466 | 74 | raise | 78 | raise |
467 | 75 | 79 | ||
468 | 76 | # Download into a temporary file, in case something goes wrong | 80 | # Download into a temporary file, in case something goes wrong |
469 | 77 | downloadfile = os.path.join(plugindir, ".download." + os.path.basename(cachefile)) | 81 | downloadfile = os.path.join(plugindir, ".download." + os.path.basename(cachefile)) |
470 | 78 | outfile = file(downloadfile, "wb") | 82 | outfile = file(downloadfile, "wb") |
471 | 79 | buf = "x" | 83 | buf = "x" |
472 | 80 | while len(buf) > 0: | 84 | while len(buf) > 0: |
473 | 81 | buf = connection.read(1024) | 85 | buf = connection.read(1024) |
474 | 82 | outfile.write(buf) | 86 | outfile.write(buf) |
475 | 83 | 87 | ||
476 | 84 | outfile.close() | 88 | outfile.close() |
477 | 85 | 89 | ||
478 | 86 | try: | 90 | try: |
479 | 87 | os.rename(downloadfile, cachefile) | 91 | os.rename(downloadfile, cachefile) |
480 | 88 | except OSError: | 92 | except OSError: |
481 | 89 | # Are we on a system that doesn't support atomic renames? | 93 | # Are we on a system that doesn't support atomic renames? |
482 | 90 | os.remove(cachefile) | 94 | os.remove(cachefile) |
483 | 91 | os.rename(downloadfile, cachefile) | 95 | os.rename(downloadfile, cachefile) |
484 | 92 | 96 | ||
485 | 93 | return cachefile | 97 | return cachefile |
486 | 94 | 98 | ||
487 | 95 | def file_in_path(program): | 99 | def file_in_path(program): |
492 | 96 | path = os.environ.get("PATH", os.defpath).split(os.pathsep) | 100 | path = os.environ.get("PATH", os.defpath).split(os.pathsep) |
493 | 97 | path = [os.path.join(dir, program) for dir in path] | 101 | path = [os.path.join(dir, program) for dir in path] |
494 | 98 | path = [True for file in path if os.path.isfile(file)] | 102 | path = [True for file in path if os.path.isfile(file)] |
495 | 99 | return bool(path) | 103 | return bool(path) |
496 | 100 | 104 | ||
497 | 101 | def unicode_output(output, errors="strict"): | 105 | def unicode_output(output, errors="strict"): |
503 | 102 | try: | 106 | try: |
504 | 103 | encoding = os.getenv("LANG").split(".")[1] | 107 | encoding = os.getenv("LANG").split(".")[1] |
505 | 104 | except: | 108 | except: |
506 | 105 | encoding = "ascii" | 109 | encoding = "ascii" |
507 | 106 | return unicode(output, encoding, errors) | 110 | return unicode(output, encoding, errors) |
508 | 107 | 111 | ||
509 | 108 | def ibid_version(): | 112 | def ibid_version(): |
511 | 109 | return resource_exists(__name__, '.version') and resource_string(__name__, '.version').strip() or None | 113 | return resource_exists(__name__, '.version') and resource_string(__name__, '.version').strip() or None |
512 | 114 | |||
513 | 115 | # vi: set et sta sw=4 ts=4: |
Pretty straight-forward. Affected modules still seem to work fine.