Some code style cleanup

darcs-hash:20070530062346-86b55-64349462a3967c5f804d6d39b59276428a15477e.gz
This commit is contained in:
David Rousselie
2007-05-30 08:23:46 +02:00
parent 78ab52627f
commit 62cca9bbc9
4 changed files with 20 additions and 32 deletions

View File

@@ -695,7 +695,6 @@ class AccountManager(object):
if new_account:
result.append(Message(\
from_jid = self.component.jid, to_jid = _account.user_jid, \
stanza_type = "normal", \
subject = _account.get_new_message_subject(lang_class), \
body = _account.get_new_message_body(lang_class)))
result.append(Presence(from_jid = _account.jid, \
@@ -704,7 +703,6 @@ class AccountManager(object):
else:
result.append(Message(\
from_jid = self.component.jid, to_jid = _account.user_jid, \
stanza_type = "normal", \
subject = _account.get_update_message_subject(lang_class), \
body = _account.get_update_message_body(lang_class)))
self.db_disconnect()
@@ -1092,7 +1090,6 @@ class AccountManager(object):
_account.waiting_password_reply = True
result.append(Message(from_jid = _account.jid, \
to_jid = _account.user_jid, \
stanza_type = "normal", \
subject = u"[PASSWORD] " + \
lang_class.ask_password_subject, \
body = lang_class.ask_password_body % \
@@ -1201,7 +1198,6 @@ class PasswordMessageHandler(Handler):
_account.waiting_password_reply = False
return [Message(from_jid = _account.jid, \
to_jid = stanza.get_from(), \
stanza_type = "normal", \
subject = lang_class.password_saved_for_session, \
body = lang_class.password_saved_for_session)]

View File

@@ -1,4 +1,4 @@
# -*- coding: UTF-8 -*-
# -*- coding: utf-8 -*-
##
## component.py
## Login : David Rousselie <dax@happycoders.org>
@@ -46,12 +46,12 @@ class FeederComponent(JCLComponent):
port,
db_connection_str,
lang = Lang()):
JCLComponent.__init__(self, \
jid, \
secret, \
server, \
port, \
db_connection_str, \
JCLComponent.__init__(self,
jid,
secret,
server,
port,
db_connection_str,
lang=lang)
# Define default feeder and sender, can be override
self.feeder = Feeder(self)
@@ -63,7 +63,7 @@ class FeederComponent(JCLComponent):
def handle_tick(self):
"""Implement main feed/send behavior"""
self.db_connect()
for _account in Account.select(clauseTables = ["account"], \
for _account in Account.select(clauseTables=["account"],
orderBy="user_jid"):
for subject, body in self.feeder.feed(_account):
self.sender.send(_account, subject, body)
@@ -95,11 +95,9 @@ class MessageSender(Sender):
def send(self, to_account, subject, body):
"""Implement abstract method from Sender class and send data as Jabber message"""
self.component.stream.send(Message(\
from_jid = to_account.jid, \
to_jid = to_account.user_jid, \
subject = subject, \
stanza_type = "normal", \
self.component.stream.send(Message(from_jid=to_account.jid,
to_jid=to_account.user_jid,
subject=subject,
body=body))
class HeadlineSender(Sender):
@@ -107,9 +105,8 @@ class HeadlineSender(Sender):
def send(self, to_account, subject, body):
"""Implement abstract method from Sender class and send data as Jabber headline"""
self.component.stream.send(Message(\
from_jid = to_account.jid, \
to_jid = to_account.user_jid, \
subject = subject, \
stanza_type = "headline", \
self.component.stream.send(Message(from_jid=to_account.jid,
to_jid=to_account.user_jid,
subject=subject,
stanza_type="headline",
body=body))

View File

@@ -2248,7 +2248,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "account11@jcl.test.com", \
stanza_type = "normal", \
subject = "[PASSWORD]", \
body = "secret")
accounts = self.handler.filter(message)
@@ -2267,7 +2266,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "account11@jcl.test.com", \
stanza_type = "normal", \
subject = "[PASSWORD]", \
body = "secret")
accounts = self.handler.filter(message)
@@ -2285,7 +2283,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "account11@jcl.test.com", \
stanza_type = "normal", \
subject = "[NOT GOOD MESSAGE]", \
body = "secret")
accounts = self.handler.filter(message)
@@ -2302,7 +2299,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "account11@jcl.test.com", \
stanza_type = "normal", \
subject = "[PASSWORD]", \
body = "secret")
accounts = self.handler.filter(message)
@@ -2319,7 +2315,6 @@ class PasswordMessageHandler_TestCase(unittest.TestCase):
jid = "account12@jcl.test.com")
message = Message(from_jid = "user1@test.com", \
to_jid = "account11@jcl.test.com", \
stanza_type = "normal", \
subject = "[PASSWORD]", \
body = "secret")
messages = self.handler.handle(message, Lang(), [account11])

View File

@@ -182,7 +182,7 @@ class MessageSender_TestCase(unittest.TestCase):
Account.createTable(ifNotExists = True)
del account.hub.threadConnection
self.sender = MessageSender(self.comp)
self.message_type = "normal"
self.message_type = None
def tearDown(self):
account.hub.threadConnection = connectionForURI('sqlite://' + DB_URL)