fix arguments order in contacts.py, some coding standards. should fix #4081

This commit is contained in:
Yann Leboulanger 2008-07-05 19:04:27 +00:00
parent 3ad1f9afed
commit 74c53da32a
6 changed files with 56 additions and 59 deletions

View File

@ -186,17 +186,20 @@ class Contacts:
sub='', ask='', resource='', priority=0, keyID='', our_chatstate=None,
chatstate=None, last_status_time=None, composing_xep=None,
mood={}, tune={}, activity={}):
return Contact(jid, name, groups, show, status, sub, ask, resource,
priority, keyID, our_chatstate, chatstate, last_status_time,
None, composing_xep, mood, tune, activity)
return Contact(jid=jid, name=name, groups=groups, show=show,
status=status, sub=sub, ask=ask, resource=resource, priority=priority,
keyID=keyID, chatstate=our_chatstate, chatstate=chatstate,
last_status_time=last_status_time, composing_xep=composing_xep,
mood=mood, tune=tune, activity=activity)
def copy_contact(self, contact):
return self.create_contact(jid = contact.jid, name = contact.name,
groups = contact.groups, show = contact.show, status =
contact.status, sub = contact.sub, ask = contact.ask, resource = contact.resource,
priority = contact.priority, keyID = contact.keyID,
our_chatstate = contact.our_chatstate, chatstate = contact.chatstate,
last_status_time = contact.last_status_time)
return self.create_contact(jid=contact.jid, name=contact.name,
groups=contact.groups, show=contact.show, status=contact.status,
sub=contact.sub, ask=contact.ask, resource=contact.resource,
priority=contact.priority, keyID=contact.keyID,
caps_node=contact.caps_node, caps_hash_method=contact.caps_hash_method,
caps_hash=contact.caps_hash, our_chatstate=contact.our_chatstate,
chatstate=contact.chatstate, last_status_time=contact.last_status_time)
def add_contact(self, account, contact):
# No such account before ?

View File

@ -1602,7 +1602,7 @@ class SubscriptionRequestWindow:
if gajim.interface.instances[self.account]['infos'].has_key(self.jid):
gajim.interface.instances[self.account]['infos'][self.jid].window.present()
else:
contact = gajim.contacts.create_contact(jid = self.jid, name='',
contact = gajim.contacts.create_contact(jid=self.jid, name='',
groups=[], show='', status='', sub='', ask='', resource='',
priority=5, keyID='', our_chatstate=None, chatstate=None)
gajim.interface.instances[self.account]['infos'][self.jid] = \

View File

@ -276,8 +276,7 @@ _('Connection with peer cannot be established.'))
if contact.find('/') == -1:
return
(jid, resource) = contact.split('/', 1)
contact = gajim.contacts.create_contact(jid = jid,
resource = resource)
contact = gajim.contacts.create_contact(jid=jid, resource=resource)
(file_dir, file_name) = os.path.split(file_path)
file_props = self.get_send_file_props(account, contact,
file_path, file_name, file_desc)

View File

@ -673,11 +673,10 @@ class Interface:
# Create SelfContact and add to roster
if resource == gajim.connections[account].server_resource:
return
contact1 = gajim.contacts.create_contact(jid = ji,
name = gajim.nicks[account], groups = ['self_contact'],
show = array[1], status = status_message, sub = 'both',
ask = 'none', priority = priority, keyID = keyID,
resource = resource)
contact1 = gajim.contacts.create_contact(jid=ji,
name=gajim.nicks[account], groups=['self_contact'],
show=array[1], status=status_message, sub='both', ask='none',
priority=priority, keyID=keyID, resource=resource)
old_show = 0
gajim.contacts.add_contact(account, contact1)
lcontact.append(contact1)
@ -869,9 +868,9 @@ class Interface:
keyID = attached_keys[attached_keys.index(jid) + 1]
name = jid.split('@', 1)[0]
name = name.split('%', 1)[0]
contact1 = gajim.contacts.create_contact(jid = jid, name = name,
groups = [], show = 'online', status = 'online',
ask = 'to', resource = array[1], keyID = keyID)
contact1 = gajim.contacts.create_contact(jid=jid, name=name,
groups=[], show='online', status='online',
ask='to', resource=array[1], keyID=keyID)
gajim.contacts.add_contact(account, contact1)
self.roster.add_contact(jid, account)
dialogs.InformationDialog(_('Authorization accepted'),
@ -1401,8 +1400,8 @@ class Interface:
if sub == 'remove':
return
# Add new contact to roster
contact = gajim.contacts.create_contact(jid = jid, name = name,
groups = groups, show = 'offline', sub = sub, ask = ask)
contact = gajim.contacts.create_contact(jid=jid, name=name,
groups=groups, show='offline', sub=sub, ask=ask)
gajim.contacts.add_contact(account, contact)
self.roster.add_contact(jid, account)
else:
@ -1540,9 +1539,9 @@ class Interface:
'attached_gpg_keys').split()
if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1]
contact = gajim.contacts.create_contact(jid = jid, name = '',
groups = [_('Not in Roster')], show = 'not in roster', status = '',
sub = 'none', keyID = keyID)
contact = gajim.contacts.create_contact(jid=jid, name='',
groups=[_('Not in Roster')], show='not in roster', status='',
sub='none', keyID=keyID)
gajim.contacts.add_contact(account, contact)
self.roster.add_contact(contact.jid, account)
file_props = array[1]
@ -2484,7 +2483,7 @@ class Interface:
return
if minimize and not minimized_control_exists and \
not self.msg_win_mgr.has_window(room_jid, account):
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
contact = gajim.contacts.create_contact(jid=room_jid, name=nick)
gc_control = GroupchatControl(None, contact, account)
self.minimized_controls[account][room_jid] = gc_control
gajim.connections[account].join_gc(nick, room_jid, password)
@ -2508,7 +2507,7 @@ class Interface:
def new_room(self, room_jid, nick, account, is_continued=False):
# Get target window, create a control, and associate it with the window
contact = gajim.contacts.create_contact(jid = room_jid, name = nick)
contact = gajim.contacts.create_contact(jid=room_jid, name=nick)
mw = self.msg_win_mgr.get_window(contact.jid, account)
if not mw:
mw = self.msg_win_mgr.create_window(contact, account,

View File

@ -731,9 +731,8 @@ class RosterWindow:
else:
show = 'offline'
status = ''
contact = gajim.contacts.create_contact(jid = jid, name = jid,
groups = [_('Groupchats')], show = show,
status = status, sub = 'none')
contact = gajim.contacts.create_contact(jid=jid, name=jid,
groups=[_('Groupchats')], show=show, status=status, sub='none')
gajim.contacts.add_contact(account, contact)
self.add_contact(jid, account)
else:
@ -758,9 +757,9 @@ class RosterWindow:
Return the added contact instance.'''
contact = gajim.contacts.get_contact_with_highest_priority(account, jid)
if contact is None:
contact = gajim.contacts.create_contact(jid = jid, name = jid,
groups = [_('Transports')], show = 'offline',
status = 'offline', sub = 'from')
contact = gajim.contacts.create_contact(jid=jid, name=jid,
groups=[_('Transports')], show='offline', status='offline',
sub='from')
gajim.contacts.add_contact(account, contact)
self.add_contact(jid, account)
return contact
@ -856,9 +855,9 @@ class RosterWindow:
'attached_gpg_keys').split()
if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1]
contact = gajim.contacts.create_contact(jid = jid, name = nick,
groups = [_('Not in Roster')], show = 'not in roster', status = '',
sub = 'none', resource = resource, keyID = keyID)
contact = gajim.contacts.create_contact(jid=jid, name=nick,
groups=[_('Not in Roster')], show='not in roster', status='',
sub='none', resource=resource, keyID=keyID)
gajim.contacts.add_contact(account, contact)
self.add_contact(contact.jid, account)
return contact
@ -1483,10 +1482,10 @@ class RosterWindow:
if gajim.jid_is_transport(jid):
array[jid]['groups'] = [_('Transports')]
contact1 = gajim.contacts.create_contact(jid = ji, name = name,
groups = array[jid]['groups'], show = show, status = status,
sub = array[jid]['subscription'], ask = array[jid]['ask'],
resource = resource, keyID = keyID)
contact1 = gajim.contacts.create_contact(jid=ji, name=name,
groups=array[jid]['groups'], show=show, status=status,
sub=array[jid]['subscription'], ask=array[jid]['ask'],
resource=resource, keyID=keyID)
gajim.contacts.add_contact(account, contact1)
if gajim.config.get('ask_avatars_on_startup'):
@ -1690,9 +1689,9 @@ class RosterWindow:
'attached_gpg_keys').split()
if jid in attached_keys:
keyID = attached_keys[attached_keys.index(jid) + 1]
contact = gajim.contacts.create_contact(jid = jid, name = nickname,
groups = groups, show = 'requested', status = '', ask = 'none',
sub = 'subscribe', keyID = keyID)
contact = gajim.contacts.create_contact(jid=jid, name=nickname,
groups=groups, show='requested', status='', ask='none',
sub='subscribe', keyID=keyID)
gajim.contacts.add_contact(account, contact)
else:
if not _('Not in Roster') in contact.get_shown_groups():
@ -2218,14 +2217,11 @@ class RosterWindow:
account_name = account
if gajim.account_is_connected(account):
account_name += ' (%s/%s)' % (repr(nbr_on), repr(nbr_total))
contact = gajim.contacts.create_contact(jid = jid,
name = account_name, show = connection.get_status(), sub = '',
status = connection.status,
resource = connection.server_resource,
priority = connection.priority,
mood = connection.mood,
tune = connection.tune,
activity = connection.activity)
contact = gajim.contacts.create_contact(jid=jid, name=account_name,
show=connection.get_status(), sub='', status=connection.status,
resource=connection.server_resource,
priority=connection.priority, mood=connection.mood,
tune=connection.tune, activity=connection.activity)
if gajim.connections[account].gpg:
contact.keyID = gajim.config.get_per('accounts', connection.name,
'keyid')
@ -2250,11 +2246,11 @@ class RosterWindow:
show = roster.getShow(jid+'/'+resource)
if not show:
show = 'online'
contact = gajim.contacts.create_contact(jid = jid,
name = account, groups = ['self_contact'], show = show,
status = roster.getStatus(jid+'/'+resource),
resource = resource,
priority = roster.getPriority(jid+'/'+resource))
contact = gajim.contacts.create_contact(jid=jid,
name=account, groups=['self_contact'], show=show,
status=roster.getStatus(jid + '/' + resource),
resource=resource,
priority=roster.getPriority(jid + '/' + resource))
contacts.append(contact)
if self.tooltip.timeout == 0 or self.tooltip.id != props[0]:
self.tooltip.id = row
@ -4542,7 +4538,7 @@ class RosterWindow:
service_discovery_menuitem.connect('activate',
self.on_service_disco_menuitem_activate, account)
hostname = gajim.config.get_per('accounts', account, 'hostname')
contact = gajim.contacts.create_contact(jid = hostname) # Fake contact
contact = gajim.contacts.create_contact(jid=hostname) # Fake contact
execute_command_menuitem.connect('activate',
self.on_execute_command, contact, account)

View File

@ -449,8 +449,8 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession):
contact = gajim.contacts.get_contact(account, self.jid, resource)
if not contact:
contact = gajim.contacts.create_contact(jid = jid,
resource = resource, show = self.conn.get_status())
contact = gajim.contacts.create_contact(jid=jid,
resource=resource, show=self.conn.get_status())
gajim.interface.new_chat(contact, account,
resource = resource, session = self)