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
=== modified file 'ibid.ini'
--- ibid.ini 2010-01-04 12:23:00 +0000
+++ ibid.ini 2010-01-14 15:07:12 +0000
@@ -12,12 +12,12 @@
12 type = irc12 type = irc
13 server = za.atrum.org13 server = za.atrum.org
14 modes = B14 modes = B
15# nickserv_password = password15 # nickserv_password = password
16 nickserv_mask = services@atrum.org16 nickserv_mask = services@atrum.org
17 [[freenode]]17 [[freenode]]
18 type = irc18 type = irc
19 server = chat.eu.freenode.net19 server = chat.eu.freenode.net
20# nickserv_password = password20 # nickserv_password = password
21 nickserv_mask = NickServ@services.21 nickserv_mask = NickServ@services.
22 disabled = True22 disabled = True
23 [[jabber]]23 [[jabber]]
2424
=== modified file 'ibid/core.py'
--- ibid/core.py 2010-01-07 12:41:26 +0000
+++ ibid/core.py 2010-01-14 15:07:12 +0000
@@ -173,8 +173,9 @@
173173
174 self.load_source(source)174 self.load_source(source)
175175
176 def load_processors(self):176 def load_processors(self, load=None, noload=None, autoload=None):
177 """Configuration:177 """If method parameters are not provided, they'll be looked up from
178 config:
178 [plugins]179 [plugins]
179 load = List of plugins / plugin.Processors to load180 load = List of plugins / plugin.Processors to load
180 noload = List of plugins / plugin.Processors to skip automatically loading181 noload = List of plugins / plugin.Processors to skip automatically loading
@@ -183,12 +184,18 @@
183 # Sets up twisted.python so that we can iterate modules184 # Sets up twisted.python so that we can iterate modules
184 __import__('ibid.plugins')185 __import__('ibid.plugins')
185186
186 load = 'load' in ibid.config.plugins and ibid.config.plugins['load'] or []187 if load is None:
187 noload = 'noload' in ibid.config.plugins and ibid.config.plugins['noload'] or []188 load = ibid.config.plugins.get('load', [])
189 if noload is None:
190 noload = ibid.config.plugins.get('noload', [])
188191
189 all_plugins = set(plugin.split('.')[0] for plugin in load)192 all_plugins = set(plugin.split('.')[0] for plugin in load)
190 if 'autoload' not in ibid.config.plugins or ibid.config.plugins['autoload'] == True:193 if autoload is None:
191 all_plugins |= set(plugin.name.replace('ibid.plugins.', '') for plugin in getModule('ibid.plugins').iterModules())194 autoload = ibid.config.plugins.get('autoload', 'True').lower() \
195 in ('true', 'yes')
196 if autoload:
197 all_plugins |= set(plugin.name.replace('ibid.plugins.', '')
198 for plugin in getModule('ibid.plugins').iterModules())
192199
193 for plugin in all_plugins:200 for plugin in all_plugins:
194 load_processors = [p.split('.')[1] for p in load if p.startswith(plugin + '.')]201 load_processors = [p.split('.')[1] for p in load if p.startswith(plugin + '.')]
195202
=== modified file 'scripts/ibid-plugin'
--- scripts/ibid-plugin 2010-01-07 12:41:26 +0000
+++ scripts/ibid-plugin 2010-01-14 15:07:12 +0000
@@ -24,12 +24,16 @@
24from ibid.event import Event24from ibid.event import Event
2525
26parser = OptionParser(usage="""%prog [options...] [plugins...]26parser = OptionParser(usage="""%prog [options...] [plugins...]
27plugins is the list of plugins to load. A plugin name followed by a - will be disabled rather than loaded.""")27plugins is the list of plugins to load.
28parser.add_option("-o", "--only", dest="load_base", action="store_false", default=True,28A plugin name followed by a - will be disabled rather than loaded.""")
29parser.add_option("-o", "--only", dest="load_base", action="store_false",
30 default=True,
29 help="Only load the specified plugins, not the common base plugins")31 help="Only load the specified plugins, not the common base plugins")
30parser.add_option("-c", "--configured", dest="load_configured", action="store_true",32parser.add_option("-c", "--configured", dest="load_configured",
31 help="Load all all configured plugins")33 action="store_true",
32parser.add_option("-p", "--public", dest="public", action="store_true", default=False,34 default=False, help="Load all all configured plugins")
35parser.add_option("-p", "--public", dest="public", action="store_true",
36 default=False,
33 help="Make testchan public, it's private by default")37 help="Make testchan public, it's private by default")
3438
35(options, args) = parser.parse_args()39(options, args) = parser.parse_args()
@@ -58,7 +62,7 @@
58ibid.reloader.reload_databases()62ibid.reloader.reload_databases()
59ibid.reloader.reload_dispatcher()63ibid.reloader.reload_dispatcher()
6064
61class TestSource(dict):65class TestSource(object):
62 type = 'test'66 type = 'test'
63 permissions = []67 permissions = []
64 supports = ('action', 'multiline', 'notice')68 supports = ('action', 'multiline', 'notice')
@@ -69,6 +73,12 @@
69 def truncation_point(self, response, event=None):73 def truncation_point(self, response, event=None):
70 return None74 return None
7175
76 def setup(self):
77 pass
78
79 def url(self):
80 return None
81
72ibid.sources[u'test_source'] = TestSource()82ibid.sources[u'test_source'] = TestSource()
7383
74load = [plugin for plugin in args if not plugin.endswith("-")]84load = [plugin for plugin in args if not plugin.endswith("-")]
@@ -77,21 +87,11 @@
77if options.load_base:87if options.load_base:
78 load.extend(("admin", "config", "core", "help", "test"))88 load.extend(("admin", "config", "core", "help", "test"))
7989
80if load:90load.extend(ibid.config.plugins.get('load', []))
81 if 'load' in ibid.config.plugins:91noload.extend(ibid.config.plugins.get('noload', []))
82 load.extend(ibid.config.plugins['load'])92autoload = options.load_configured
83 ibid.config.plugins['load'] = load93
8494ibid.reloader.load_processors(load, noload, autoload)
85if noload:
86 if 'noload' in ibid.config.plugins:
87 ibid.config.plugins['noload'].extend(noload)
88 else:
89 ibid.config.plugins['noload'] = noload
90
91if not options.load_configured:
92 ibid.config.plugins['autoload'] = False
93
94ibid.reloader.load_processors()
9595
96username = unicode(getenv('USER'))96username = unicode(getenv('USER'))
97if not username:97if not username:

Subscribers

People subscribed via source and target branches