Merge lp:~stefanor/ibid/ibid-plugin-507489 into lp:~ibid-core/ibid/old-trunk-1.6

Proposed by Stefano Rivera
Status: Merged
Approved by: Michael Gorven
Approved revision: 842
Merged at revision: 861
Proposed branch: lp:~stefanor/ibid/ibid-plugin-507489
Merge into: lp:~ibid-core/ibid/old-trunk-1.6
Diff against target: 132 lines (+36/-29)
3 files modified
ibid.ini (+2/-2)
ibid/core.py (+13/-6)
scripts/ibid-plugin (+21/-21)
To merge this branch: bzr merge lp:~stefanor/ibid/ibid-plugin-507489
Reviewer Review Type Date Requested Status
Michael Gorven Approve
Max Rabkin Approve
marcog (community) Approve
Jonathan Hitchcock Approve
Review via email: mp+17382@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote :

This branch was kicked off by Marco trying to set a configuration value in ibid-plugin. Then I noticed his "ibid-plugin -c" wasn't doing the right thing any more. I believe this fixes everything.

Revision history for this message
Jonathan Hitchcock (vhata) :
review: Approve
Revision history for this message
marcog (marco-gallotta) wrote :

pyflakes complains (see below), but I think it can be ignored.

scripts/ibid-plugin:21: redefinition of unused 'ibid' from line 20

Looks good though.

review: Approve
Revision history for this message
Max Rabkin (max-rabkin) wrote :

Looks OK.

review: Approve
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.ini'
2--- ibid.ini 2010-01-04 12:23:00 +0000
3+++ ibid.ini 2010-01-14 15:07:12 +0000
4@@ -12,12 +12,12 @@
5 type = irc
6 server = za.atrum.org
7 modes = B
8-# nickserv_password = password
9+ # nickserv_password = password
10 nickserv_mask = services@atrum.org
11 [[freenode]]
12 type = irc
13 server = chat.eu.freenode.net
14-# nickserv_password = password
15+ # nickserv_password = password
16 nickserv_mask = NickServ@services.
17 disabled = True
18 [[jabber]]
19
20=== modified file 'ibid/core.py'
21--- ibid/core.py 2010-01-07 12:41:26 +0000
22+++ ibid/core.py 2010-01-14 15:07:12 +0000
23@@ -173,8 +173,9 @@
24
25 self.load_source(source)
26
27- def load_processors(self):
28- """Configuration:
29+ def load_processors(self, load=None, noload=None, autoload=None):
30+ """If method parameters are not provided, they'll be looked up from
31+ config:
32 [plugins]
33 load = List of plugins / plugin.Processors to load
34 noload = List of plugins / plugin.Processors to skip automatically loading
35@@ -183,12 +184,18 @@
36 # Sets up twisted.python so that we can iterate modules
37 __import__('ibid.plugins')
38
39- load = 'load' in ibid.config.plugins and ibid.config.plugins['load'] or []
40- noload = 'noload' in ibid.config.plugins and ibid.config.plugins['noload'] or []
41+ if load is None:
42+ load = ibid.config.plugins.get('load', [])
43+ if noload is None:
44+ noload = ibid.config.plugins.get('noload', [])
45
46 all_plugins = set(plugin.split('.')[0] for plugin in load)
47- if 'autoload' not in ibid.config.plugins or ibid.config.plugins['autoload'] == True:
48- all_plugins |= set(plugin.name.replace('ibid.plugins.', '') for plugin in getModule('ibid.plugins').iterModules())
49+ if autoload is None:
50+ autoload = ibid.config.plugins.get('autoload', 'True').lower() \
51+ in ('true', 'yes')
52+ if autoload:
53+ all_plugins |= set(plugin.name.replace('ibid.plugins.', '')
54+ for plugin in getModule('ibid.plugins').iterModules())
55
56 for plugin in all_plugins:
57 load_processors = [p.split('.')[1] for p in load if p.startswith(plugin + '.')]
58
59=== modified file 'scripts/ibid-plugin'
60--- scripts/ibid-plugin 2010-01-07 12:41:26 +0000
61+++ scripts/ibid-plugin 2010-01-14 15:07:12 +0000
62@@ -24,12 +24,16 @@
63 from ibid.event import Event
64
65 parser = OptionParser(usage="""%prog [options...] [plugins...]
66-plugins is the list of plugins to load. A plugin name followed by a - will be disabled rather than loaded.""")
67-parser.add_option("-o", "--only", dest="load_base", action="store_false", default=True,
68+plugins is the list of plugins to load.
69+A plugin name followed by a - will be disabled rather than loaded.""")
70+parser.add_option("-o", "--only", dest="load_base", action="store_false",
71+ default=True,
72 help="Only load the specified plugins, not the common base plugins")
73-parser.add_option("-c", "--configured", dest="load_configured", action="store_true",
74- help="Load all all configured plugins")
75-parser.add_option("-p", "--public", dest="public", action="store_true", default=False,
76+parser.add_option("-c", "--configured", dest="load_configured",
77+ action="store_true",
78+ default=False, help="Load all all configured plugins")
79+parser.add_option("-p", "--public", dest="public", action="store_true",
80+ default=False,
81 help="Make testchan public, it's private by default")
82
83 (options, args) = parser.parse_args()
84@@ -58,7 +62,7 @@
85 ibid.reloader.reload_databases()
86 ibid.reloader.reload_dispatcher()
87
88-class TestSource(dict):
89+class TestSource(object):
90 type = 'test'
91 permissions = []
92 supports = ('action', 'multiline', 'notice')
93@@ -69,6 +73,12 @@
94 def truncation_point(self, response, event=None):
95 return None
96
97+ def setup(self):
98+ pass
99+
100+ def url(self):
101+ return None
102+
103 ibid.sources[u'test_source'] = TestSource()
104
105 load = [plugin for plugin in args if not plugin.endswith("-")]
106@@ -77,21 +87,11 @@
107 if options.load_base:
108 load.extend(("admin", "config", "core", "help", "test"))
109
110-if load:
111- if 'load' in ibid.config.plugins:
112- load.extend(ibid.config.plugins['load'])
113- ibid.config.plugins['load'] = load
114-
115-if noload:
116- if 'noload' in ibid.config.plugins:
117- ibid.config.plugins['noload'].extend(noload)
118- else:
119- ibid.config.plugins['noload'] = noload
120-
121-if not options.load_configured:
122- ibid.config.plugins['autoload'] = False
123-
124-ibid.reloader.load_processors()
125+load.extend(ibid.config.plugins.get('load', []))
126+noload.extend(ibid.config.plugins.get('noload', []))
127+autoload = options.load_configured
128+
129+ibid.reloader.load_processors(load, noload, autoload)
130
131 username = unicode(getenv('USER'))
132 if not username:

Subscribers

People subscribed via source and target branches