Merge lp:~stefanor/ibid/botdir-data into lp:~ibid-core/ibid/old-trunk-1.6

Proposed by Stefano Rivera
Status: Merged
Approved by: Michael Gorven
Approved revision: 883
Merged at revision: 884
Proposed branch: lp:~stefanor/ibid/botdir-data
Merge into: lp:~ibid-core/ibid/old-trunk-1.6
Diff against target: 162 lines (+28/-17)
6 files modified
ibid/config.py (+2/-2)
ibid/plugins/meetings.py (+1/-1)
ibid/plugins/urlgrab.py (+7/-9)
ibid/source/http.py (+5/-4)
ibid/utils/__init__.py (+12/-0)
scripts/ibid-plugin (+1/-1)
To merge this branch: bzr merge lp:~stefanor/ibid/botdir-data
Reviewer Review Type Date Requested Status
Michael Gorven Approve
Keegan Carruthers-Smith Approve
Jonathan Hitchcock Approve
Review via email: mp+18750@code.launchpad.net

This proposal supersedes a proposal from 2010-02-06.

To post a comment you must log in.
Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve
Revision history for this message
Keegan Carruthers-Smith (keegan-csmith) wrote :

Looks good. I am not that familiar with ibid core, but i was wondering what would happen if we were running ibid from an egg. Would stuff like this break? (My guess is no since you will use defaultish type values)

review: Approve
Revision history for this message
Stefano Rivera (stefanor) wrote :

> (My guess is no since you will use defaultish type values)

At the moment, ibid isn't eggable

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

 review approve
 status approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/config.py'
2--- ibid/config.py 2010-01-17 20:17:23 +0000
3+++ ibid/config.py 2010-02-06 10:03:13 +0000
4@@ -5,9 +5,9 @@
5
6 from configobj import ConfigObj
7 from validate import Validator
8-from pkg_resources import resource_stream
9
10 import ibid
11+from ibid.utils import locate_resource
12
13 def monkeypatch(self, name):
14 if self.has_key(name):
15@@ -17,7 +17,7 @@
16 ConfigObj.__getattr__ = monkeypatch
17
18 def FileConfig(filename):
19- spec = resource_stream(__name__, 'configspec.ini')
20+ spec = file(locate_resource('ibid', 'configspec.ini'), 'r')
21 configspec = ConfigObj(spec, list_values=False, encoding='utf-8')
22 config = ConfigObj(filename, configspec=configspec, interpolation='Template', encoding='utf-8')
23 config.validate(Validator())
24
25=== modified file 'ibid/plugins/meetings.py'
26--- ibid/plugins/meetings.py 2010-01-18 23:20:33 +0000
27+++ ibid/plugins/meetings.py 2010-02-06 10:03:13 +0000
28@@ -17,12 +17,12 @@
29 from ibid.compat import json
30 from ibid.config import BoolOption, IntOption, Option
31 from ibid.plugins import Processor, match, authorise
32+from ibid.source.http import templates
33 from ibid.utils import format_date, plural
34
35 help = {}
36 log = logging.getLogger('plugins.meetings')
37
38-templates = Environment(loader=PackageLoader('ibid', 'templates'))
39 meetings = {}
40
41 help['meeting'] = u'Take minutes of an IRC Meeting'
42
43=== modified file 'ibid/plugins/urlgrab.py'
44--- ibid/plugins/urlgrab.py 2010-01-25 09:23:49 +0000
45+++ ibid/plugins/urlgrab.py 2010-02-06 10:03:13 +0000
46@@ -8,13 +8,12 @@
47 import logging
48 import re
49
50-from pkg_resources import resource_exists, resource_stream
51-
52 import ibid
53 from ibid.plugins import Processor, handler
54 from ibid.config import Option
55 from ibid.db import IbidUnicode, IbidUnicodeText, Integer, DateTime, \
56 Table, Column, ForeignKey, Base, VersionedSchema
57+from ibid.utils import locate_resource
58 from ibid.utils.html import get_html_parse_tree
59
60 help = {}
61@@ -61,13 +60,12 @@
62 'delicious')
63
64 def setup(self):
65- if resource_exists(__name__, '../data/tlds-alpha-by-domain.txt'):
66- tlds = [tld.strip().lower() for tld
67- in resource_stream(__name__, '../data/tlds-alpha-by-domain.txt')
68- .readlines()
69- if not tld.startswith('#')
70- ]
71-
72+ tldfile = locate_resource('ibid', 'data/tlds-alpha-by-domain.txt')
73+ if tldfile:
74+ f = file(tldfile, 'r')
75+ tlds = [tld.strip().lower() for tld in f.readlines()
76+ if not tld.startswith('#')]
77+ f.close()
78 else:
79 log.warning(u"Couldn't open TLD list, falling back to minimal default")
80 tlds = 'com.org.net.za'.split('.')
81
82=== modified file 'ibid/source/http.py'
83--- ibid/source/http.py 2010-01-18 22:53:52 +0000
84+++ ibid/source/http.py 2010-02-06 10:03:13 +0000
85@@ -6,15 +6,16 @@
86 from twisted.web import server, resource, static, xmlrpc, soap
87 from twisted.application import internet
88 from twisted.internet import reactor
89-from pkg_resources import resource_filename
90-from jinja import Environment, PackageLoader
91+from jinja import Environment, FileSystemLoader
92
93 import ibid
94 from ibid.source import IbidSourceFactory
95 from ibid.event import Event
96 from ibid.config import Option, IntOption
97+from ibid.utils import locate_resource
98
99-templates = Environment(loader=PackageLoader('ibid', 'templates'))
100+templates = Environment(loader=FileSystemLoader(
101+ locate_resource('ibid', 'templates')))
102
103 class Index(resource.Resource):
104
105@@ -101,7 +102,7 @@
106 root = Plugin(name)
107 root.putChild('', Index(name))
108 root.putChild('message', Message(name))
109- root.putChild('static', static.File(resource_filename('ibid', 'static')))
110+ root.putChild('static', static.File(locate_resource('ibid', 'static')))
111 root.putChild('RPC2', XMLRPC())
112 root.putChild('SOAP', SOAP())
113 self.site = server.Site(root)
114
115=== removed file 'ibid/templates/__init__.py'
116=== modified file 'ibid/utils/__init__.py'
117--- ibid/utils/__init__.py 2010-02-03 11:48:04 +0000
118+++ ibid/utils/__init__.py 2010-02-06 10:03:13 +0000
119@@ -17,6 +17,7 @@
120 import zlib
121
122 from dateutil.tz import tzlocal, tzutc
123+from pkg_resources import resource_exists, resource_filename
124
125 import ibid
126 from ibid.compat import defaultdict, json
127@@ -228,4 +229,15 @@
128 return singular
129 return plural
130
131+def locate_resource(path, filename):
132+ "Locate a resource either within the botdir or the source tree"
133+ fspath = os.path.join(*(
134+ [ibid.options['base']] + path.split('.') + [filename]
135+ ))
136+ if os.path.exists(fspath):
137+ return fspath
138+ if not resource_exists(path, filename):
139+ return None
140+ return resource_filename(path, filename)
141+
142 # vi: set et sta sw=4 ts=4:
143
144=== modified file 'scripts/ibid-plugin'
145--- scripts/ibid-plugin 2010-01-29 16:35:04 +0000
146+++ scripts/ibid-plugin 2010-02-06 10:03:13 +0000
147@@ -20,7 +20,6 @@
148 sys.path.insert(0, '.')
149
150 import ibid
151-import ibid.plugins
152 from ibid.config import FileConfig
153 from ibid.db.models import Identity
154 from ibid.event import Event
155@@ -57,6 +56,7 @@
156
157 #ibid.plugins.auth_responses = auth_responses
158 ibid.options = {'base': '.'}
159+import ibid.plugins
160
161 logging.basicConfig(level=logging.DEBUG)
162 ibid.config = FileConfig("ibid.ini")

Subscribers

People subscribed via source and target branches