From a06fa2de677afad437622216fac7971b727ac569 Mon Sep 17 00:00:00 2001 From: Lance Stout Date: Thu, 26 Jul 2012 23:04:16 -0700 Subject: Enhance plugin config with attribute accessors. This makes updating the config after plugin initialization much easier. --- sleekxmpp/plugins/xep_0092/version.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'sleekxmpp/plugins/xep_0092') diff --git a/sleekxmpp/plugins/xep_0092/version.py b/sleekxmpp/plugins/xep_0092/version.py index 463da158..35813e1d 100644 --- a/sleekxmpp/plugins/xep_0092/version.py +++ b/sleekxmpp/plugins/xep_0092/version.py @@ -30,16 +30,18 @@ class XEP_0092(BasePlugin): description = 'XEP-0092: Software Version' dependencies = set(['xep_0030']) stanza = stanza + default_config = { + 'software_name': 'SleekXMPP', + 'version': sleekxmpp.__version__, + 'os': '' + } def plugin_init(self): """ Start the XEP-0092 plugin. """ - self.name = self.config.get('name', 'SleekXMPP') - self.version = self.config.get('version', sleekxmpp.__version__) - self.os = self.config.get('os', '') - - self.getVersion = self.get_version + if 'name' in self.config: + self.software_name = self.config['name'] self.xmpp.register_handler( Callback('Software Version', @@ -63,7 +65,7 @@ class XEP_0092(BasePlugin): iq -- The Iq stanza containing the software version query. """ iq.reply() - iq['software_version']['name'] = self.name + iq['software_version']['name'] = self.software_name iq['software_version']['version'] = self.version iq['software_version']['os'] = self.os iq.send() @@ -88,3 +90,6 @@ class XEP_0092(BasePlugin): del values['lang'] return values return False + + +XEP_0092.getVersion = XEP_0092.get_version -- cgit v1.2.3