remove the use of string module in logger.py

This commit is contained in:
Yann Leboulanger 2005-03-11 00:13:21 +00:00
parent edd6088448
commit df9b1de0da
1 changed files with 11 additions and 12 deletions

View File

@ -50,7 +50,6 @@ if __name__ == "__main__":
sys.exit() sys.exit()
import os import os
import string
import time import time
import common.optparser import common.optparser
from common import i18n from common import i18n
@ -76,7 +75,7 @@ class plugin:
print _("plugin logger stopped") print _("plugin logger stopped")
return return
elif ev[0] == 'NOTIFY': elif ev[0] == 'NOTIFY':
jid = string.split(ev[2][0], '/')[0] jid = ev[2][0].split('/')[0]
if jid in self.no_log_for[ev[1]]: if jid in self.no_log_for[ev[1]]:
break break
if ev[1] in self.no_log_for[ev[1]]: if ev[1] in self.no_log_for[ev[1]]:
@ -84,7 +83,7 @@ class plugin:
status = ev[2][2] status = ev[2][2]
if not status: if not status:
status = "" status = ""
status = string.replace(status, '\n', '\\n') status = status.replace('\n', '\\n')
if lognotsep == 1: if lognotsep == 1:
fic = open(LOGPATH + "notify.log", "a") fic = open(LOGPATH + "notify.log", "a")
fic.write("%s:%s:%s:%s\n" % (tim, ev[2][0] + '/' + ev[2][3], \ fic.write("%s:%s:%s:%s\n" % (tim, ev[2][0] + '/' + ev[2][3], \
@ -96,33 +95,33 @@ class plugin:
ev[2][1], status)) ev[2][1], status))
fic.close() fic.close()
elif ev[0] == 'MSG': elif ev[0] == 'MSG':
jid = string.split(ev[2][0], '/')[0] jid = ev[2][0].split('/')[0]
if jid in self.no_log_for[ev[1]]: if jid in self.no_log_for[ev[1]]:
break break
if ev[1] in self.no_log_for[ev[1]]: if ev[1] in self.no_log_for[ev[1]]:
break break
msg = string.replace(ev[2][1], '\n', '\\n') msg = ev[2][1].replace('\n', '\\n')
fic = open(LOGPATH + jid, "a") fic = open(LOGPATH + jid, "a")
t = time.mktime(ev[2][2]) t = time.mktime(ev[2][2])
fic.write("%s:recv:%s\n" % (t, msg)) fic.write("%s:recv:%s\n" % (t, msg))
fic.close() fic.close()
elif ev[0] == 'MSGSENT': elif ev[0] == 'MSGSENT':
jid = string.split(ev[2][0], '/')[0] jid = ev[2][0].split('/')[0]
if jid in self.no_log_for[ev[1]]: if jid in self.no_log_for[ev[1]]:
break break
if ev[1] in self.no_log_for[ev[1]]: if ev[1] in self.no_log_for[ev[1]]:
break break
msg = string.replace(ev[2][1], '\n', '\\n') msg = ev[2][1].replace('\n', '\\n')
fic = open(LOGPATH + jid, "a") fic = open(LOGPATH + jid, "a")
fic.write("%s:sent:%s\n" % (tim, msg)) fic.write("%s:sent:%s\n" % (tim, msg))
fic.close() fic.close()
elif ev[0] == 'GC_MSG': elif ev[0] == 'GC_MSG':
msg = string.replace(ev[2][1], '\n', '\\n') msg = ev[2][1].replace('\n', '\\n')
jids = string.split(ev[2][0], '/') jids = ev[2][0].split('/')
jid = jids[0] jid = jids[0]
nick = '' nick = ''
if len(jids) > 1: if len(jids) > 1:
nick = string.split(ev[2][0], '/')[1] nick = ev[2][0].split('/')[1]
fic = open(LOGPATH + jid, "a") fic = open(LOGPATH + jid, "a")
t = time.mktime(ev[2][2]) t = time.mktime(ev[2][2])
fic.write("%s:recv:%s:%s\n" % (t, nick, msg)) fic.write("%s:recv:%s:%s\n" % (t, nick, msg))
@ -137,7 +136,7 @@ class plugin:
self.no_log_for[acct] = [] self.no_log_for[acct] = []
if accounts[acct].has_key('no_log_for'): if accounts[acct].has_key('no_log_for'):
self.no_log_for[acct] = \ self.no_log_for[acct] = \
string.split(accounts[acct]['no_log_for'], ' ') accounts[acct]['no_log_for'].split()
time.sleep(0.1) time.sleep(0.1)
def wait(self, what): def wait(self, what):
@ -165,7 +164,7 @@ class plugin:
self.no_log_for[acct] = [] self.no_log_for[acct] = []
if accounts[acct].has_key('no_log_for'): if accounts[acct].has_key('no_log_for'):
self.no_log_for[acct] = \ self.no_log_for[acct] = \
string.split(accounts[acct]['no_log_for'], ' ') accounts[acct]['no_log_for'].split()
#create ~/.gajim/logs/ if it doesn't exist #create ~/.gajim/logs/ if it doesn't exist
try: try:
os.stat(os.path.expanduser("~/.gajim")) os.stat(os.path.expanduser("~/.gajim"))