Fix pep8 support in src/plugins.

This commit is contained in:
Emmanuel Gil Peyrot 2013-01-18 17:55:35 +01:00
commit 0dca274360

View file

@ -34,21 +34,22 @@ try:
except ImportError:
from wokkel.subprotocols import XMPPHandler
MESSAGE= '/message'
MESSAGE = '/message'
NS_DIRECT_MUC_INVITATION = 'jabber:x:conference'
DIRECT_MUC_INVITATION_REQUEST = MESSAGE + '/x[@xmlns="' + NS_DIRECT_MUC_INVITATION + '"]'
PLUGIN_INFO = {
"name": "XEP 0249 Plugin",
"import_name": "XEP-0249",
"type": "XEP",
"protocols": ["XEP-0249"],
"dependencies": ["XEP-0045"],
"main": "XEP_0249",
"handler": "yes",
"description": _("""Implementation of Direct MUC Invitations""")
"name": "XEP 0249 Plugin",
"import_name": "XEP-0249",
"type": "XEP",
"protocols": ["XEP-0249"],
"dependencies": ["XEP-0045"],
"main": "XEP_0249",
"handler": "yes",
"description": _("""Implementation of Direct MUC Invitations""")
}
class XEP_0249(object):
def __init__(self, host):
@ -71,15 +72,15 @@ class XEP_0249(object):
if not profile:
error(_("Profile doesn't exists !"))
return
message = domish.Element((None,'message'))
message = domish.Element((None, 'message'))
message["to"] = target.full()
x_elt = message.addElement('x',NS_DIRECT_MUC_INVITATION)
x_elt = message.addElement('x', NS_DIRECT_MUC_INVITATION)
x_elt['jid'] = room.userhost()
for opt in options:
x_elt[opt] = options[opt]
self.host.profiles[profile].xmlstream.send(message)
def _invite(self, target, service, roomId, options = {}, profile_key='@DEFAULT@'):
def _invite(self, target, service, roomId, options={}, profile_key='@DEFAULT@'):
"""
Invite an user to a room
@param target: jid of the user to invite
@ -90,14 +91,13 @@ class XEP_0249(object):
#TODO: check parameters validity
self.invite(jid.JID(target), jid.JID("%s@%s" % (roomId, service)), options, profile_key)
def onInvitation(self, message, profile):
"""
called when an invitation is received
@param message: message element
@profile: %(doc_profile)s
"""
info(_('Invitation received for room %(room)s [%(profile)s]') % {'room':'','profile':profile})
info(_('Invitation received for room %(room)s [%(profile)s]') % {'room': '', 'profile': profile})
try:
room = jid.JID(message.firstChildElement()['jid'])
except:
@ -116,7 +116,7 @@ class XEP_0249_handler(XMPPHandler):
self.host = plugin_parent.host
def connectionInitialized(self):
self.xmlstream.addObserver(DIRECT_MUC_INVITATION_REQUEST, self.plugin_parent.onInvitation, profile = self.parent.profile)
self.xmlstream.addObserver(DIRECT_MUC_INVITATION_REQUEST, self.plugin_parent.onInvitation, profile=self.parent.profile)
def getDiscoInfo(self, requestor, target, nodeIdentifier=''):
return [disco.DiscoFeature(NS_DIRECT_MUC_INVITATION)]