PLEASE HAVE A LOOK. string module is deprecated. starting to change in order not to be deprecated. PLEASE HAVE A LOOK. I DID 2 times, maybe I missed sth though. split(' ') --> split() is the same so that's not an error [sep=' '] is the default one [and I don't expect that to change :P

This commit is contained in:
Nikos Kouremenos 2005-03-05 21:02:38 +00:00
parent c9d65729df
commit 893358edfe
4 changed files with 89 additions and 87 deletions

View File

@ -3,6 +3,7 @@
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <nkour@jabber.org>
##
## Copyright (C) 2003-2005 Gajim Team
##
@ -16,11 +17,17 @@
## GNU General Public License for more details.
##
import sys, os, time, string, logging
import sys
import os
import time
import logging
import common.hub, common.optparser
import common.hub
import common.optparser
import common.jabber
import socket, select, pickle
import socket
import select
import pickle
from tempfile import *
from common import i18n
@ -75,11 +82,11 @@ else:
while 1:
line = child_stdout.readline()
if line == "": break
line = string.rstrip( line )
line = line.rstrip()
if line[0:9] == '[GNUPG:] ':
# Chop off the prefix
line = line[9:]
L = string.split(line, None, 1)
L = line.split(None, 1)
keyword = L[0]
if len(L) > 1:
resp[ keyword ] = L[1]
@ -162,9 +169,9 @@ else:
keyid = ''
if resp.has_key('GOODSIG'):
keyid = string.split(resp['GOODSIG'])[0]
keyid = resp['GOODSIG'].split()[0]
elif resp.has_key('BADSIG'):
keyid = string.split(resp['BADSIG'])[0]
keyid = resp['BADSIG'].split()[0]
return keyid
def get_secret_keys(self):
@ -174,9 +181,9 @@ else:
proc.handles['stdout'].close()
keys = {}
lines = string.split(output, '\n')
lines = output.split('\n')
for line in lines:
sline = string.split(line, ':')
sline = line.split(':')
if sline[0] == 'sec':
keys[sline[4][8:]] = sline[9]
return keys
@ -185,7 +192,7 @@ else:
def stripHeaderFooter(self, data):
"""Remove header and footer from data"""
lines = string.split(data, '\n')
lines = data.split('\n')
while lines[0] != '':
lines.remove(lines[0])
while lines[0] == '':
@ -195,7 +202,7 @@ else:
if line:
if line[0] == '-': break
i = i+1
line = string.join(lines[0:i], '\n')
line = '\n'.join(lines[0:i])
return line
def addHeaderFooter(self, data, type):
@ -248,7 +255,7 @@ class GajimCore:
"""Load defaults plugins : plugins in 'modules' option of Core section
in ConfFile and register them to the hub"""
if moduleStr:
mods = string.split (moduleStr, ' ')
mods = moduleStr.split(' ')
for mod in mods:
try:
@ -277,7 +284,7 @@ class GajimCore:
default_tab = {'Profile': {'log': 0}, 'Core_client': {'host': \
'localhost', 'port': 8255, 'modules': 'gtkgui'}}
fname = os.path.expanduser(CONFPATH)
reps = string.split(fname, '/')
reps = fname.split('/')
path = ''
while len(reps) > 1:
path = path + reps[0] + '/'
@ -315,7 +322,7 @@ class GajimCore:
if self.mode == 'server':
self.accounts = {}
if self.cfgParser.tab['Profile'].has_key('accounts'):
accts = string.split(self.cfgParser.tab['Profile']['accounts'], ' ')
accts = self.cfgParser.tab['Profile']['accounts'].split()
if accts == ['']:
accts = []
for a in accts:
@ -419,9 +426,9 @@ class GajimCore:
elif typ == 'subscribe':
log.debug("subscribe request from %s" % who)
if self.cfgParser.Core['alwaysauth'] == 1 or \
string.find(who, "@") <= 0:
who.find("@") <= 0:
con.send(common.jabber.Presence(who, 'subscribed'))
if string.find(who, "@") <= 0:
if who.find("@") <= 0:
self.hub.sendPlugin('NOTIFY', self.connexions[con], \
(prs.getFrom().getStripped(), 'offline', 'offline', \
prs.getFrom().getResource(), prio, keyID, None, None, None, \
@ -656,8 +663,7 @@ class GajimCore:
elif ev[0] == 'CONFIG':
if ev[2][0] == 'accounts':
#Remove all old accounts
accts = string.split(self.cfgParser.tab\
['Profile']['accounts'], ' ')
accts = self.cfgParser.tab['Profile']['accounts'].split()
if accts == ['']:
accts = []
for a in accts:
@ -665,7 +671,7 @@ class GajimCore:
#Write all new accounts
accts = ev[2][1].keys()
self.cfgParser.tab['Profile']['accounts'] = \
string.join(accts)
' '.join(accts)
for a in accts:
self.cfgParser.tab[a] = ev[2][1][a]
if not a in self.connected.keys():
@ -889,7 +895,7 @@ class GajimCore:
line = fic.readline()
nb = nb+1
if line:
lineSplited = string.split(line, ':')
lineSplited = line.split(':')
if len(lineSplited) > 2:
self.hub.sendPlugin('LOG_LINE', ev[1], (ev[2][0], nb, \
lineSplited[0], lineSplited[1], lineSplited[2:]))

View File

@ -3,7 +3,8 @@
## Gajim Team:
## - Yann Le Boulanger <asterix@lagaule.org>
## - Vincent Hanquez <tab@snarc.org>
## - Nikos Kouremenos <nkour@jabber.org>
## - Nikos Kouremenos <nkour@jabber.org>
## - Alex Podaras <bigpod@jabber.org>
##
## Copyright (C) 2003-2005 Gajim Team
##
@ -17,13 +18,10 @@
## GNU General Public License for more details.
##
import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade
import gobject
import os
import string
import common.sleepy
from common import i18n
_ = i18n._
@ -141,7 +139,7 @@ class preferences_window:
emots.append(model.get_value(iter, 0))
emots.append(model.get_value(iter, 1))
iter = model.iter_next(iter)
self.plugin.config['emoticons'] = string.join(emots, '\t')
self.plugin.config['emoticons'] = '\t'.join(emots)
#use emoticons
chk = self.xml.get_widget('use_emoticons_checkbutton')
if chk.get_active():
@ -311,7 +309,7 @@ class preferences_window:
def load_emots(self):
emots = {}
split_line = string.split(self.plugin.config['emoticons'], '\t')
split_line = self.plugin.config['emoticons'].split('\t')
for i in range(0, len(split_line)/2):
if not self.image_is_ok(split_line[2*i+1]):
continue
@ -834,33 +832,33 @@ class account_window:
proxyhost = self.xml.get_widget('proxyhost_entry').get_text()
proxyport = self.xml.get_widget('proxyport_entry').get_text()
if (name == ''):
warning_dialog(_('You must enter a name for this account'))
Warning_dialog(_('You must enter a name for this account'))
return 0
if name.find(' ') != -1:
warning_dialog(_('Spaces are not permited in account name'))
Warning_dialog(_('Spaces are not permited in account name'))
return 0
if (jid == '') or (string.count(jid, '@') != 1):
warning_dialog(_('You must enter a Jabber ID for this account\nFor example: someone@someserver.org'))
if (jid == '') or (jid.count('@') != 1):
Warning_dialog(_('You must enter a Jabber ID for this account\nFor example: someone@someserver.org'))
return 0
if new_account_checkbutton.get_active() and password == '':
warning_dialog(_('You must enter a password to register a new account'))
Warning_dialog(_('You must enter a password to register a new account'))
return 0
if use_proxy:
if proxyport != '':
try:
proxyport = string.atoi(proxyport)
proxyport = int(proxyport)
except ValueError:
warning_dialog(_('Proxy Port must be a port number'))
Warning_dialog(_('Proxy Port must be a port number'))
return 0
if proxyhost == '':
warning_dialog(_('You must enter a proxy host to use proxy'))
Warning_dialog(_('You must enter a proxy host to use proxy'))
if priority != '':
try:
priority = string.atoi(priority)
priority = int(priority)
except ValueError:
warning_dialog(_('Priority must be a number'))
Warning_dialog(_('Priority must be a number'))
return 0
(login, hostname) = string.split(jid, '@')
(login, hostname) = jid.split('@')
key_name = self.xml.get_widget('gpg_name_label').get_text()
if key_name == '': #no key selected
keyID = ''
@ -916,7 +914,7 @@ class account_window:
return
#if it's a new account
if name in self.plugin.accounts.keys():
warning_dialog(_('An account already has this name'))
Warning_dialog(_('An account already has this name'))
return
#if we neeed to register a new account
if new_account_checkbutton.get_active():
@ -982,7 +980,7 @@ class account_window:
vcard_information_window(jid, self.plugin, self.account, True)
self.plugin.send('ASK_VCARD', self.account, jid)
else:
warning_dialog(_('You must be connected to get your informations'))
Warning_dialog(_('You must be connected to get your informations'))
def on_gpg_choose_button_clicked(self, widget, data=None):
w = choose_gpg_key_dialog()
@ -1285,8 +1283,8 @@ class agent_browser_window:
return
service = model.get_value(iter, 1)
room = ''
if string.find(service, '@') > -1:
services = string.split(service, '@')
if service.find('@') > -1:
services = service.split('@')
room = services[0]
service = services[1]
if not self.plugin.windows.has_key('join_gc'):
@ -1320,7 +1318,7 @@ class agent_browser_window:
def __init__(self, plugin, account):
if not plugin.connected[account]:
warning_dialog(_("You must be connected to view Agents"))
Warning_dialog(_("You must be connected to view Agents"))
return
xml = gtk.glade.XML(GTKGUI_GLADE, 'agent_browser_window', APP)
self.window = xml.get_widget('agent_browser_window')

View File

@ -21,7 +21,6 @@
import gtk
import gtk.glade
import gobject
import string
from common import i18n
_ = i18n._
APP = i18n.APP
@ -67,7 +66,7 @@ class vcard_information_window:
if log and self.user.jid in no_log_for:
no_log_for.remove(self.user.jid)
if oldlog != log:
account_info['no_log_for'] = string.join(no_log_for, ' ')
account_info['no_log_for'] = ' '.join(no_log_for)
self.plugin.accounts[self.account] = account_info
self.plugin.send('CONFIG', None, ('accounts', self.plugin.accounts, \
'Gtkgui'))
@ -122,7 +121,7 @@ class vcard_information_window:
def add_to_vcard(self, vcard, entry, txt):
"""Add an information to the vCard dictionary"""
entries = string.split(entry, '_')
entries = '_'.split(entry)
loc = vcard
while len(entries) > 1:
if not loc.has_key(entries[0]):
@ -389,7 +388,7 @@ class add_contact_window:
#If login contains only numbers, it's probably an ICQ number
try:
string.atoi(uid)
int(uid) # will raise ValueError if not all numbers
except:
pass
else:

View File

@ -44,7 +44,7 @@ if __name__ == "__main__":
sock.connect(('', 8255))
except:
#TODO: use i18n
print "unable to connect to localhost on port "+str(port)
print "unable to connect to localhost on port ", port
else:
evp = pickle.dumps(('EXEC_PLUGIN', '', 'gtkgui'))
sock.send('<'+evp+'>')
@ -57,7 +57,6 @@ import gtk
import gtk.glade
import gobject
import os
import string
import time
import Queue
import sys
@ -551,12 +550,12 @@ class tabbed_chat_window:
conversation_textview = self.xmls[jid].get_widget('conversation_textview')
conversation_buffer = conversation_textview.get_buffer()
if not text:
text = ""
text = ''
end_iter = conversation_buffer.get_end_iter()
if not tim:
tim = time.localtime()
tims = time.strftime("[%H:%M:%S]", tim)
conversation_buffer.insert(end_iter, tims + ' ')
tim_format = time.strftime("[%H:%M:%S]", tim)
conversation_buffer.insert(end_iter, tim_format + ' ')
otext = ''
ttext = ''
@ -571,7 +570,7 @@ class tabbed_chat_window:
tag = 'incoming'
name = user.name
if string.find(text, '/me ') == 0:
if text.find('/me ') == 0:
ttext = name + ' ' + text[4:] + '\n'
else:
ttext = '<' + name + '> '
@ -898,20 +897,20 @@ class Groupchat_window:
message_textview.grab_focus()
'''
def print_conversation(self, txt, room_jid, contact = None, tim = None):
def print_conversation(self, text, room_jid, contact = None, tim = None):
"""Print a line in the conversation :
if contact is set : it's a message from someone
if contact is not set : it's a message from the server"""
conversation_textview = self.xmls[room_jid].\
get_widget('conversation_textview')
conversation_buffer = conversation_textview.get_buffer()
if not txt:
txt = ""
if not text:
text = ''
end_iter = conversation_buffer.get_end_iter()
if not tim:
tim = time.localtime()
tims = time.strftime('[%H:%M:%S]', tim)
conversation_buffer.insert(end_iter, tims)
tim_format = time.strftime('[%H:%M:%S]', time)
conversation_buffer.insert(end_iter, tim_format) # CHECK! in tabbed print_conver you have + ' ' here
if contact:
if contact == self.nicks[room_jid]:
conversation_buffer.insert_with_tags_by_name(end_iter, '<' + \
@ -919,9 +918,9 @@ class Groupchat_window:
else:
conversation_buffer.insert_with_tags_by_name(end_iter, '<' + \
contact + '> ', 'incoming')
conversation_buffer.insert(end_iter, txt + '\n')
conversation_buffer.insert(end_iter, text + '\n')
else:
conversation_buffer.insert_with_tags_by_name(end_iter, txt + '\n', \
conversation_buffer.insert_with_tags_by_name(end_iter, text + '\n', \
'status')
#scroll to the end of the textview
conversation_textview.scroll_to_mark(conversation_buffer.get_mark('end'),\
@ -1328,18 +1327,18 @@ class history_window:
tim = time.strftime("[%x %X] ", time.localtime(float(infos[1])))
self.history_buffer.insert(start_iter, tim)
if infos[2] == 'recv':
msg = string.join(infos[3][0:], ':')
msg = string.replace(msg, '\\n', '\n')
msg = ':'.join(infos[3][0:])
msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, msg, \
'incoming')
elif infos[2] == 'sent':
msg = string.join(infos[3][0:], ':')
msg = string.replace(msg, '\\n', '\n')
msg = ':'.join(infos[3][0:])
msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, msg, \
'outgoing')
else:
msg = string.join(infos[3][1:], ':')
msg = string.replace(msg, '\\n', '\n')
msg = ':'.join(infos[3][1:], ':')
msg = msg.replace('\\n', '\n')
self.history_buffer.insert_with_tags_by_name(start_iter, \
_('Status is now : ') + infos[3][0]+' : ' + msg, 'status')
@ -1450,7 +1449,7 @@ class roster_window:
users = self.contacts[account][jid]
user = users[0]
if user.groups == []:
if string.find(user.jid, "@") <= 0:
if user.jid.find("@") <= 0:
user.groups.append('Agents')
else:
user.groups.append('general')
@ -1607,7 +1606,7 @@ class roster_window:
if not self.groups.has_key(account):
self.groups[account] = {}
for jid in array.keys():
jids = string.split(jid, '/')
jids = jid.split('/')
#get jid
ji = jids[0]
#get resource
@ -1617,10 +1616,10 @@ class roster_window:
#get name
name = array[jid]['name']
if not name:
if string.find(ji, "@") <= 0:
if ji.find("@") <= 0:
name = ji
else:
name = string.split(jid, '@')[0]
name = jid.split('@')[0]
#get show
show = array[jid]['show']
if not show:
@ -2217,7 +2216,7 @@ class roster_window:
self.plugin.config['width'], self.plugin.config['height'] = \
self.window.get_size()
self.plugin.config['hiddenlines'] = string.join(self.hidden_lines, '\t')
self.plugin.config['hiddenlines'] = '\t'.join(self.hidden_lines)
self.plugin.send('CONFIG', None, ('GtkGui', self.plugin.config, 'GtkGui'))
self.plugin.send('QUIT', None, ('gtkgui', 1))
print _("plugin gtkgui stopped")
@ -2353,7 +2352,7 @@ class roster_window:
"""initialize emoticons dictionary"""
self.emoticons = dict()
self.begin_emot = ''
split_line = string.split(self.plugin.config['emoticons'], '\t')
split_line = self.plugin.config['emoticons'].split('\t')
for i in range(0, len(split_line)/2):
file = split_line[2*i+1]
if not self.image_is_ok(file):
@ -2610,7 +2609,7 @@ class roster_window:
self.xml.signal_autoconnect(self)
self.id_signal_cb = self.cb.connect('changed', self.on_cb_changed)
self.hidden_lines = string.split(self.plugin.config['hiddenlines'], '\t')
self.hidden_lines = self.plugin.config['hiddenlines'].split('\t')
self.draw_roster()
class systrayDummy:
@ -2722,7 +2721,7 @@ class systray:
user = users[0]
if group in user.groups and user.show != 'offline' and \
user.show != 'error':
item = gtk.MenuItem(string.replace(user.name, '_', '__'))
item = gtk.MenuItem(user.name.replace('_', '__'))
menu_user.append(item)
item.connect("activate", self.start_chat, account, user.jid)
@ -2840,7 +2839,7 @@ class plugin:
try:
os.execvp(argv[0], argv)
except:
print _("error while running %s :") % string.join(argv, ' '), \
print _("error while running %s :") % ' '.join(argv), \
sys.exc_info()[1]
os._exit(1)
pidp, r = os.waitpid(pid, os.WNOHANG)
@ -2892,15 +2891,15 @@ class plugin:
# role, affiliation, real_jid, reason, actor, statusCode))
statuss = ['offline', 'error', 'online', 'chat', 'away', 'xa', 'dnd', 'invisible']
old_show = 0
jid = string.split(array[0], '/')[0]
jid = array[0].split('/')[0]
keyID = array[5]
resource = array[3]
if not resource:
resource = ''
priority = array[4]
if string.find(jid, "@") <= 0:
if jid.find("@") <= 0:
#It must be an agent
ji = string.replace(jid, '@', '')
ji = jid.replace('@', '')
else:
ji = jid
#Update user
@ -2920,7 +2919,7 @@ class plugin:
if user1.show in statuss:
old_show = statuss.index(user1.show)
if (resources != [''] and (len(luser) != 1 or
luser[0].show != 'offline')) and not string.find(jid, "@") <= 0:
luser[0].show != 'offline')) and not jid.find("@") <= 0:
old_show = 0
user1 = User(user1.jid, user1.name, user1.groups, user1.show, \
user1.status, user1.sub, user1.ask, user1.resource, \
@ -2931,7 +2930,7 @@ class plugin:
user1.status = array[2]
user1.priority = priority
user1.keyID = keyID
if string.find(jid, "@") <= 0:
if jid.find("@") <= 0:
#It must be an agent
if self.roster.contacts[account].has_key(ji):
#Update existing iter
@ -2955,9 +2954,9 @@ class plugin:
def handle_event_msg(self, account, array):
#('MSG', account, (user, msg, time))
jid = string.split(array[0], '/')[0]
if string.find(jid, "@") <= 0:
jid = string.replace(jid, '@', '')
jid = array[0].split('/')[0]
if jid.find("@") <= 0:
jid = jid.replace('@', '')
first = 0
if not self.windows[account]['chats'].has_key(jid) and \
not self.queues[account].has_key(jid):
@ -2970,9 +2969,9 @@ class plugin:
def handle_event_msgerror(self, account, array):
#('MSGERROR', account, (user, error_code, error_msg, msg, time))
jid = string.split(array[0], '/')[0]
if string.find(jid, "@") <= 0:
jid = string.replace(jid, '@', '')
jid = array[0].split('/')[0]
if jid.find("@") <= 0:
jid = jid.replace('@', '')
self.roster.on_message(jid, _("error while sending") + " \"%s\" ( %s )"%\
(array[3], array[2]), array[4], account)
@ -3085,7 +3084,7 @@ class plugin:
def handle_event_gc_msg(self, account, array):
#('GC_MSG', account, (jid, msg, time))
jids = string.split(array[0], '/')
jids = array[0].split('/')
jid = jids[0]
if not self.windows[account]['gc'].has_key(jid):
return
@ -3103,7 +3102,7 @@ class plugin:
def handle_event_gc_subject(self, account, array):
#('GC_SUBJECT', account, (jid, subject))
jids = string.split(array[0], '/')
jids = array[0].split('/')
jid = jids[0]
if not self.windows[account]['gc'].has_key(jid):
return