fix var name (conflict with module name)

This commit is contained in:
Yann Leboulanger 2007-11-08 18:03:16 +00:00
parent 973f4bcc49
commit cc19d02377

View file

@ -192,19 +192,19 @@ class ProfileWindow:
except AttributeError: except AttributeError:
pass pass
def set_values(self, vcard): def set_values(self, vcard_):
button = self.xml.get_widget('PHOTO_button') button = self.xml.get_widget('PHOTO_button')
image = button.get_image() image = button.get_image()
text_button = self.xml.get_widget('NOPHOTO_button') text_button = self.xml.get_widget('NOPHOTO_button')
if not 'PHOTO' in vcard: if not 'PHOTO' in vcard_:
# set default image # set default image
image.set_from_pixbuf(None) image.set_from_pixbuf(None)
button.hide() button.hide()
text_button.show() text_button.show()
for i in vcard.keys(): for i in vcard_.keys():
if i == 'PHOTO': if i == 'PHOTO':
pixbuf, self.avatar_encoded, self.avatar_mime_type = \ pixbuf, self.avatar_encoded, self.avatar_mime_type = \
vcard.get_avatar_pixbuf_encoded_mime(vcard[i]) vcard.get_avatar_pixbuf_encoded_mime(vcard_[i])
if not pixbuf: if not pixbuf:
image.set_from_pixbuf(None) image.set_from_pixbuf(None)
button.hide() button.hide()
@ -216,21 +216,21 @@ class ProfileWindow:
text_button.hide() text_button.hide()
continue continue
if i == 'ADR' or i == 'TEL' or i == 'EMAIL': if i == 'ADR' or i == 'TEL' or i == 'EMAIL':
for entry in vcard[i]: for entry in vcard_[i]:
add_on = '_HOME' add_on = '_HOME'
if 'WORK' in entry: if 'WORK' in entry:
add_on = '_WORK' add_on = '_WORK'
for j in entry.keys(): for j in entry.keys():
self.set_value(i + add_on + '_' + j + '_entry', entry[j]) self.set_value(i + add_on + '_' + j + '_entry', entry[j])
if isinstance(vcard[i], dict): if isinstance(vcard_[i], dict):
for j in vcard[i].keys(): for j in vcard_[i].keys():
self.set_value(i + '_' + j + '_entry', vcard[i][j]) self.set_value(i + '_' + j + '_entry', vcard_[i][j])
else: else:
if i == 'DESC': if i == 'DESC':
self.xml.get_widget('DESC_textview').get_buffer().set_text( self.xml.get_widget('DESC_textview').get_buffer().set_text(
vcard[i], 0) vcard_[i], 0)
else: else:
self.set_value(i + '_entry', vcard[i]) self.set_value(i + '_entry', vcard_[i])
if self.update_progressbar_timeout_id is not None: if self.update_progressbar_timeout_id is not None:
if self.message_id: if self.message_id:
self.statusbar.remove(self.context_id, self.message_id) self.statusbar.remove(self.context_id, self.message_id)
@ -243,10 +243,10 @@ class ProfileWindow:
self.progressbar.set_fraction(0) self.progressbar.set_fraction(0)
self.update_progressbar_timeout_id = None self.update_progressbar_timeout_id = None
def add_to_vcard(self, vcard, entry, txt): def add_to_vcard(self, vcard_, entry, txt):
'''Add an information to the vCard dictionary''' '''Add an information to the vCard dictionary'''
entries = entry.split('_') entries = entry.split('_')
loc = vcard loc = vcard_
if len(entries) == 3: # We need to use lists if len(entries) == 3: # We need to use lists
if not loc.has_key(entries[0]): if not loc.has_key(entries[0]):
loc[entries[0]] = [] loc[entries[0]] = []
@ -259,14 +259,14 @@ class ProfileWindow:
e[entries[2]] = txt e[entries[2]] = txt
else: else:
loc[entries[0]].append({entries[1]: '', entries[2]: txt}) loc[entries[0]].append({entries[1]: '', entries[2]: txt})
return vcard return vcard_
while len(entries) > 1: while len(entries) > 1:
if not loc.has_key(entries[0]): if not loc.has_key(entries[0]):
loc[entries[0]] = {} loc[entries[0]] = {}
loc = loc[entries[0]] loc = loc[entries[0]]
del entries[0] del entries[0]
loc[entries[0]] = txt loc[entries[0]] = txt
return vcard return vcard_
def make_vcard(self): def make_vcard(self):
'''make the vCard dictionary''' '''make the vCard dictionary'''
@ -277,11 +277,11 @@ class ProfileWindow:
'ORG_ORGUNIT', 'TITLE', 'ROLE', 'TEL_WORK_NUMBER', 'EMAIL_WORK_USERID', 'ORG_ORGUNIT', 'TITLE', 'ROLE', 'TEL_WORK_NUMBER', 'EMAIL_WORK_USERID',
'ADR_WORK_STREET', 'ADR_WORK_EXTADR', 'ADR_WORK_LOCALITY', 'ADR_WORK_STREET', 'ADR_WORK_EXTADR', 'ADR_WORK_LOCALITY',
'ADR_WORK_REGION', 'ADR_WORK_PCODE', 'ADR_WORK_CTRY'] 'ADR_WORK_REGION', 'ADR_WORK_PCODE', 'ADR_WORK_CTRY']
vcard = {} vcard_ = {}
for e in entries: for e in entries:
txt = self.xml.get_widget(e + '_entry').get_text().decode('utf-8') txt = self.xml.get_widget(e + '_entry').get_text().decode('utf-8')
if txt != '': if txt != '':
vcard = self.add_to_vcard(vcard, e, txt) vcard_ = self.add_to_vcard(vcard_, e, txt)
# DESC textview # DESC textview
buff = self.xml.get_widget('DESC_textview').get_buffer() buff = self.xml.get_widget('DESC_textview').get_buffer()
@ -289,14 +289,14 @@ class ProfileWindow:
end_iter = buff.get_end_iter() end_iter = buff.get_end_iter()
txt = buff.get_text(start_iter, end_iter, 0) txt = buff.get_text(start_iter, end_iter, 0)
if txt != '': if txt != '':
vcard['DESC'] = txt.decode('utf-8') vcard_['DESC'] = txt.decode('utf-8')
# Avatar # Avatar
if self.avatar_encoded: if self.avatar_encoded:
vcard['PHOTO'] = {'BINVAL': self.avatar_encoded} vcard_['PHOTO'] = {'BINVAL': self.avatar_encoded}
if self.avatar_mime_type: if self.avatar_mime_type:
vcard['PHOTO']['TYPE'] = self.avatar_mime_type vcard_['PHOTO']['TYPE'] = self.avatar_mime_type
return vcard return vcard_
def on_ok_button_clicked(self, widget): def on_ok_button_clicked(self, widget):
if self.update_progressbar_timeout_id: if self.update_progressbar_timeout_id:
@ -307,14 +307,14 @@ class ProfileWindow:
_('Without a connection you can not publish your contact ' _('Without a connection you can not publish your contact '
'information.')) 'information.'))
return return
vcard = self.make_vcard() vcard_ = self.make_vcard()
nick = '' nick = ''
if vcard.has_key('NICKNAME'): if vcard_.has_key('NICKNAME'):
nick = vcard['NICKNAME'] nick = vcard_['NICKNAME']
if nick == '': if nick == '':
nick = gajim.config.get_per('accounts', self.account, 'name') nick = gajim.config.get_per('accounts', self.account, 'name')
gajim.nicks[self.account] = nick gajim.nicks[self.account] = nick
gajim.connections[self.account].send_vcard(vcard) gajim.connections[self.account].send_vcard(vcard_)
self.message_id = self.statusbar.push(self.context_id, self.message_id = self.statusbar.push(self.context_id,
_('Sending profile...')) _('Sending profile...'))
self.progressbar.show() self.progressbar.show()