Cosmetic PEP8 fixes.

This commit is contained in:
Lance Stout 2011-08-04 22:37:22 -07:00
parent 93a4a3f8a0
commit 47bc50d9fb
6 changed files with 17 additions and 13 deletions

View file

@ -141,7 +141,7 @@ class BaseXMPP(XMLStream):
def process(self, *args, **kwargs): def process(self, *args, **kwargs):
""" """
Overrides XMLStream.process. Overrides XMLStream.process.
Initialize the XML streams and begin processing events. Initialize the XML streams and begin processing events.
The number of threads used for processing stream events is determined The number of threads used for processing stream events is determined
@ -185,12 +185,14 @@ class BaseXMPP(XMLStream):
if not module: if not module:
try: try:
module = sleekxmpp.plugins module = sleekxmpp.plugins
module = __import__(str("%s.%s" % (module.__name__, plugin)), module = __import__(
globals(), locals(), [str(plugin)]) str("%s.%s" % (module.__name__, plugin)),
globals(), locals(), [str(plugin)])
except ImportError: except ImportError:
module = sleekxmpp.features module = sleekxmpp.features
module = __import__(str("%s.%s" % (module.__name__, plugin)), module = __import__(
globals(), locals(), [str(plugin)]) str("%s.%s" % (module.__name__, plugin)),
globals(), locals(), [str(plugin)])
if isinstance(module, str): if isinstance(module, str):
# We probably want to load a module from outside # We probably want to load a module from outside
# the sleekxmpp package, so leave out the globals(). # the sleekxmpp package, so leave out the globals().

View file

@ -29,7 +29,6 @@ class feature_mechanisms(base_plugin):
self.description = "SASL Stream Feature" self.description = "SASL Stream Feature"
self.stanza = stanza self.stanza = stanza
def tls_active(): def tls_active():
return 'starttls' in self.xmpp.features return 'starttls' in self.xmpp.features

View file

@ -42,9 +42,9 @@ class Mechanisms(ElementBase):
""" """
self.del_mechanisms() self.del_mechanisms()
for val in values: for val in values:
mech = ET.Element('{%s}mechanism' % self.namespace) mech = ET.Element('{%s}mechanism' % self.namespace)
mech.text = val mech.text = val
self.append(mech) self.append(mech)
def del_mechanisms(self): def del_mechanisms(self):
""" """

View file

@ -589,5 +589,5 @@ class xep_0050(base_plugin):
elif iq['type'] == 'error': elif iq['type'] == 'error':
self.terminate_command(session) self.terminate_command(session)
if iq['command']['status'] == 'completed': if iq['command']['status'] == 'completed':
self.terminate_command(session) self.terminate_command(session)

View file

@ -318,9 +318,11 @@ class SleekTest(unittest.TestCase):
self.xmpp.socket.recv_data(header) self.xmpp.socket.recv_data(header)
elif socket == 'live': elif socket == 'live':
self.xmpp.socket_class = TestLiveSocket self.xmpp.socket_class = TestLiveSocket
def wait_for_session(x): def wait_for_session(x):
self.xmpp.socket.clear() self.xmpp.socket.clear()
skip_queue.put('started') skip_queue.put('started')
self.xmpp.add_event_handler('session_start', wait_for_session) self.xmpp.add_event_handler('session_start', wait_for_session)
self.xmpp.connect() self.xmpp.connect()
else: else:

View file

@ -482,7 +482,8 @@ class ElementBase(object):
if plugin: if plugin:
if plugin not in self.plugins: if plugin not in self.plugins:
self.init_plugin(plugin) self.init_plugin(plugin)
handler = getattr(self.plugins[plugin], set_method, None) handler = getattr(self.plugins[plugin],
set_method, None)
if handler: if handler:
return handler(value) return handler(value)
@ -1066,7 +1067,7 @@ class ElementBase(object):
stanza_ns = '' if top_level_ns else self.namespace stanza_ns = '' if top_level_ns else self.namespace
return tostring(self.xml, xmlns='', return tostring(self.xml, xmlns='',
stanza_ns=stanza_ns, stanza_ns=stanza_ns,
top_level = not top_level_ns) top_level=not top_level_ns)
def __repr__(self): def __repr__(self):
""" """
@ -1285,7 +1286,7 @@ class StanzaBase(ElementBase):
return tostring(self.xml, xmlns='', return tostring(self.xml, xmlns='',
stanza_ns=stanza_ns, stanza_ns=stanza_ns,
stream=self.stream, stream=self.stream,
top_level = not top_level_ns) top_level=not top_level_ns)
# To comply with PEP8, method names now use underscores. # To comply with PEP8, method names now use underscores.