remove call to unicode()

This commit is contained in:
Yann Leboulanger 2013-01-01 21:06:16 +01:00
parent 414e349345
commit 069bddbbcb
47 changed files with 189 additions and 256 deletions

View File

@ -281,8 +281,6 @@ class CommandWindow:
# close old stage
self.stage_finish()
assert isinstance(self.commandnode, unicode)
self.form_status = None
self.stages_notebook.set_current_page(
@ -608,7 +606,6 @@ class CommandWindow:
Send the command with data form. Wait for reply
"""
# create the stanza
assert isinstance(self.commandnode, unicode)
assert action in ('execute', 'prev', 'next', 'complete')
stanza = nbxmpp.Iq(typ='set', to=self.jid)

View File

@ -2505,7 +2505,7 @@ class ChatControl(ChatControlBase):
if num_unread == 1 and not gajim.config.get('show_unread_tab_icon'):
unread = '*'
elif num_unread > 1:
unread = '[' + unicode(num_unread) + ']'
unread = '[' + str(num_unread) + ']'
# Draw tab label using chatstate
theme = gajim.config.get('roster_theme')

View File

@ -32,7 +32,7 @@ over the process.
"""
from types import NoneType
from tools import remove
from .tools import remove
COMMANDS = {}
CONTAINERS = {}

View File

@ -23,10 +23,10 @@ import re
from types import FunctionType
from inspect import getargspec, getdoc
from dispatcher import Host, Container
from dispatcher import get_command, list_commands
from mapping import parse_arguments, adapt_arguments
from errors import DefinitionError, CommandError, NoCommandError
from .dispatcher import Host, Container
from .dispatcher import get_command, list_commands
from mmapping import parse_arguments, adapt_arguments
from .errors import DefinitionError, CommandError, NoCommandError
class CommandHost(object):
"""

View File

@ -35,7 +35,7 @@ detected.
"""
from ..framework import CommandContainer, command, doc
from hosts import *
from .hosts import *
class CustomCommonCommands(CommandContainer):
"""

View File

@ -38,7 +38,7 @@ from os.path import expanduser
from glib import timeout_add
from ..framework import CommandContainer, command, doc
from hosts import *
from .hosts import *
class Execute(CommandContainer):
AUTOMATIC = True

View File

@ -30,8 +30,8 @@ from ..errors import CommandError
from ..framework import CommandContainer, command, doc
from ..mapping import generate_usage
from hosts import *
import execute
from .hosts import *
from . import execute
# This holds constants fron the logger, which we'll be using in some of our
# commands.

View File

@ -26,7 +26,7 @@ import re
from types import BooleanType, UnicodeType
from operator import itemgetter
from errors import DefinitionError, CommandError
from .errors import DefinitionError, CommandError
# Quite complex piece of regular expression logic to parse options and
# arguments. Might need some tweaking along the way.
@ -269,12 +269,6 @@ def adapt_arguments(command, arguments, args, opts):
if not isinstance(value, BooleanType):
raise CommandError("%s: Switch can not take an argument" % key, command)
# We need to encode every keyword argument to a simple string, not
# the unicode one, because ** expansion does not support it.
for index, (key, value) in enumerate(opts):
if isinstance(key, UnicodeType):
opts[index] = (key.encode(KEY_ENCODING), value)
# Inject the source arguments as a string as a first argument, if
# command has enabled the corresponding option.
if command.source:

View File

@ -29,7 +29,7 @@ import sys
import stat
from common import gajim
import logger
from common import logger
from common import jingle_xtls
# DO NOT MOVE ABOVE OF import gajim

View File

@ -23,9 +23,9 @@
##
import nbxmpp
import helpers
import dataforms
import gajim
from common import helpers
from common import dataforms
from common import gajim
import logging
log = logging.getLogger('gajim.c.commands')

View File

@ -61,7 +61,7 @@ def fse(s):
"""
Convert from filesystem encoding if not already Unicode
"""
return unicode(s, sys.getfilesystemencoding())
return s
def windowsify(s):
if os.name == 'nt':

View File

@ -616,7 +616,7 @@ class CommonConnection:
if realm == '':
if event == nbxmpp.transports_nb.DATA_RECEIVED:
gajim.nec.push_incoming_event(StanzaReceivedEvent(None,
conn=self, stanza_str=unicode(data, errors='ignore')))
conn=self, stanza_str=data))
elif event == nbxmpp.transports_nb.DATA_SENT:
gajim.nec.push_incoming_event(StanzaSentEvent(None, conn=self,
stanza_str=data))
@ -1446,7 +1446,7 @@ class Connection(CommonConnection, ConnectionHandlers):
self.connection.send(' ')
def _on_xmpp_ping_answer(self, iq_obj):
id_ = unicode(iq_obj.getAttr('id'))
id_ = iq_obj.getAttr('id')
assert id_ == self.awaiting_xmpp_ping_id
self.awaiting_xmpp_ping_id = None
@ -1607,7 +1607,7 @@ class Connection(CommonConnection, ConnectionHandlers):
self.activate_privacy_rule('invisible')
self.connected = gajim.SHOW_LIST.index('invisible')
self.status = msg
priority = unicode(gajim.get_priority(self.name, 'invisible'))
priority = gajim.get_priority(self.name, 'invisible')
p = nbxmpp.Presence(priority=priority)
p = self.add_sha(p, True)
if msg:
@ -1781,7 +1781,7 @@ class Connection(CommonConnection, ConnectionHandlers):
p.setStatus(msg)
else:
signed = self.get_signed_presence(msg)
priority = unicode(gajim.get_priority(self.name, sshow))
priority = gajim.get_priority(self.name, sshow)
p = nbxmpp.Presence(typ=None, priority=priority, show=sshow, to=jid)
p = self.add_sha(p)
if msg:
@ -1805,7 +1805,7 @@ class Connection(CommonConnection, ConnectionHandlers):
def _update_status(self, show, msg):
xmpp_show = helpers.get_xmpp_show(show)
priority = unicode(gajim.get_priority(self.name, xmpp_show))
priority = gajim.get_priority(self.name, xmpp_show)
p = nbxmpp.Presence(typ=None, priority=priority, show=xmpp_show)
p = self.add_sha(p)
if msg:

View File

@ -39,7 +39,7 @@ from time import (altzone, daylight, gmtime, localtime, mktime, strftime,
from calendar import timegm
import nbxmpp
import common.caps_cache as capscache
from common import caps_cache as capscache
from common import helpers
from common import gajim
@ -181,8 +181,8 @@ class ConnectionDisco:
if not self.connection or self.connected < 2:
return
frm = helpers.get_full_jid_from_iq(iq_obj)
to = unicode(iq_obj.getAttr('to'))
id_ = unicode(iq_obj.getAttr('id'))
to = iq_obj.getAttr('to')
id_ = iq_obj.getAttr('id')
iq = nbxmpp.Iq(to=frm, typ='result', queryNS=nbxmpp.NS_DISCO, frm=to)
iq.setAttr('id', id_)
query = iq.setTag('query')
@ -235,7 +235,7 @@ class ConnectionDisco:
if self.commandInfoQuery(con, iq_obj):
raise nbxmpp.NodeProcessed
id_ = unicode(iq_obj.getAttr('id'))
id_ = iq_obj.getAttr('id')
if id_[:6] == 'Gajim_':
# We get this request from echo.server
raise nbxmpp.NodeProcessed

View File

@ -39,7 +39,7 @@ from nbxmpp.protocol import NS_CHATSTATES
from common.jingle_transport import JingleTransportSocks5
from common.file_props import FilesProp
import gtkgui_helpers
from . import gtkgui_helpers
import logging
log = logging.getLogger('gajim.c.connection_handlers_events')
@ -1169,7 +1169,6 @@ class ZeroconfMessageReceivedEvent(MessageReceivedEvent):
self.fjid = key
break
self.fjid = unicode(self.fjid)
self.jid, self.resource = gajim.get_room_and_nick_from_fjid(self.fjid)
def generate(self):
@ -1986,7 +1985,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
self.FT_content.session.ourjid)
self.FT_content.transport.set_connection(
self.FT_content.session.connection)
sid = unicode(self.stanza.getTag('jingle').getAttr('sid'))
sid = self.stanza.getTag('jingle').getAttr('sid')
self.file_props = FilesProp.getNewFileProp(self.conn.name, sid)
self.file_props.transport_sid = self.FT_content.transport.sid
self.FT_content.file_props = self.file_props
@ -2033,8 +2032,7 @@ class FileRequestReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
else:
si = self.stanza.getTag('si')
self.file_props = FilesProp.getNewFileProp(self.conn.name,
unicode(si.getAttr('id'))
)
si.getAttr('id'))
profile = si.getAttr('profile')
if profile != nbxmpp.NS_FILE:
self.conn.send_file_rejection(self.file_props, code='400',

View File

@ -27,7 +27,7 @@ information how to use them, read documentation
"""
import nbxmpp
import helpers
from common import helpers
# exceptions used in this module
# base class
@ -345,7 +345,7 @@ class StringField(DataField):
@nested_property
def value():
"""
Value of field. May be any unicode string
Value of field. May be any string
"""
def fget(self):
return self.getTagData('value') or ''

View File

@ -31,10 +31,10 @@ import sys
import logging
import locale
import config
from common import config
import nbxmpp
import defs
import common.ged
from common import defs
from common import ged
interface = None # The actual interface (the gtk one for the moment)
thread_interface = None # Interface to run a thread and then a callback
@ -280,13 +280,8 @@ def get_jid_without_resource(jid):
return jid.split('/')[0]
def construct_fjid(room_jid, nick):
"""
Nick is in UTF-8 (taken from treeview); room_jid is in unicode
"""
# fake jid is the jid for a contact in a room
# gaim@conference.jabber.org/nick
if isinstance(nick, str):
nick = unicode(nick, 'utf-8')
return room_jid + '/' + nick
def get_resource_from_jid(jid):

View File

@ -26,7 +26,7 @@ from gajim import HAVE_GPG
import os
if HAVE_GPG:
import gnupg
from common import gnupg
class GnuPG(gnupg.GPG):
def __init__(self, use_agent=False):

View File

@ -42,7 +42,7 @@ import select
import base64
import hashlib
import shlex
import caps_cache
from common import caps_cache
import socket
import time
@ -159,7 +159,7 @@ def prep(user, server, resource):
raise InvalidFormat, _('Username must be between 1 and 1023 chars')
try:
from nbxmpp.stringprepare import nodeprep
user = nodeprep.prepare(unicode(user)).encode('utf-8')
user = nodeprep.prepare(user)
except UnicodeError:
raise InvalidFormat, _('Invalid character in username.')
else:
@ -170,7 +170,7 @@ def prep(user, server, resource):
raise InvalidFormat, _('Server must be between 1 and 1023 chars')
try:
from nbxmpp.stringprepare import nameprep
server = nameprep.prepare(unicode(server)).encode('utf-8')
server = nameprep.prepare(server)
except UnicodeError:
raise InvalidFormat, _('Invalid character in hostname.')
else:
@ -181,7 +181,7 @@ def prep(user, server, resource):
raise InvalidFormat, _('Resource must be between 1 and 1023 chars')
try:
from nbxmpp.stringprepare import resourceprep
resource = resourceprep.prepare(unicode(resource)).encode('utf-8')
resource = resourceprep.prepare(resource)
except UnicodeError:
raise InvalidFormat, _('Invalid character in resource.')
else:
@ -448,43 +448,43 @@ def get_output_of_command(command):
return output
def decode_string(string):
"""
Try to decode (to make it Unicode instance) given string
"""
if isinstance(string, unicode):
return string
# by the time we go to iso15 it better be the one else we show bad characters
encodings = (locale.getpreferredencoding(), 'utf-8', 'iso-8859-15')
for encoding in encodings:
try:
string = string.decode(encoding)
except UnicodeError:
continue
break
#def decode_string(string):
#"""
#Try to decode (to make it Unicode instance) given string
#"""
#if isinstance(string, unicode):
#return string
## by the time we go to iso15 it better be the one else we show bad characters
#encodings = (locale.getpreferredencoding(), 'utf-8', 'iso-8859-15')
#for encoding in encodings:
#try:
#string = string.decode(encoding)
#except UnicodeError:
#continue
#break
return string
#return string
def ensure_utf8_string(string):
"""
Make sure string is in UTF-8
"""
try:
string = decode_string(string).encode('utf-8')
except Exception:
pass
return string
#def ensure_utf8_string(string):
#"""
#Make sure string is in UTF-8
#"""
#try:
#string = decode_string(string).encode('utf-8')
#except Exception:
#pass
#return string
def wrapped_ensure_utf8_string(fn):
def wrapped(n):
return ensure_utf8_string(n)
return wrapped
#def wrapped_ensure_utf8_string(fn):
#def wrapped(n):
#return ensure_utf8_string(n)
#return wrapped
@wrapped_ensure_utf8_string
def escape_text(text):
return GObject.markup_escape_text(text)
#@wrapped_ensure_utf8_string
#def escape_text(text):
#return GObject.markup_escape_text(text)
GObject.markup_escape_text = escape_text
#GObject.markup_escape_text = escape_text
def get_windows_reg_env(varname, default=''):
"""
@ -645,13 +645,13 @@ def convert_bytes(string):
# but do we use the standard?
use_kib_mib = gajim.config.get('use_kib_mib')
align = 1024.
bytes = float(string)
if bytes >= align:
bytes = round(bytes/align, 1)
if bytes >= align:
bytes = round(bytes/align, 1)
if bytes >= align:
bytes = round(bytes/align, 1)
bytes_ = float(string)
if bytes_ >= align:
bytes_ = round(bytes_/align, 1)
if bytes_ >= align:
bytes_ = round(bytes_/align, 1)
if bytes_ >= align:
bytes_ = round(bytes_/align, 1)
if use_kib_mib:
#GiB means gibibyte
suffix = _('%s GiB')
@ -675,7 +675,7 @@ def convert_bytes(string):
else:
#B means bytes
suffix = _('%s B')
return suffix % unicode(bytes)
return suffix % str(bytes_)
def get_contact_dict_for_account(account):
"""
@ -901,13 +901,13 @@ def get_icon_name_to_show(contact, account = None):
def get_full_jid_from_iq(iq_obj):
"""
Return the full jid (with resource) from an iq as unicode
Return the full jid (with resource) from an iq
"""
return parse_jid(str(iq_obj.getFrom()))
return parse_jid(iq_obj.getFrom())
def get_jid_from_iq(iq_obj):
"""
Return the jid (without resource) from an iq as unicode
Return the jid (without resource) from an iq
"""
jid = get_full_jid_from_iq(iq_obj)
return gajim.get_jid_without_resource(jid)

View File

@ -24,7 +24,7 @@
import locale
import gettext
import os
import defs
from common import defs
import unicodedata
def paragraph_direction_mark(text):
@ -61,7 +61,7 @@ if os.name == 'nt':
if lang:
os.environ['LANG'] = lang
gettext.install(APP, DIR, unicode=False)
gettext.install(APP, DIR)
if gettext._translations:
_translation = gettext._translations.values()[0]
else:

View File

@ -158,7 +158,7 @@ def send_cert_request(con, to_jid):
pubkey = iq.setTag('pubkeys')
pubkey.setNamespace(nbxmpp.NS_PUBKEY_PUBKEY)
con.connection.send(iq)
return unicode(id_)
return str(id_)
# the following code is partly due to pyopenssl examples

View File

@ -46,7 +46,7 @@ def kwallet_get(folder, entry):
folder: The top-level category to use (normally the programme name)
entry: The key of the entry to retrieve
Returns the passphrase as unicode, False if it cannot be found,
Returns the passphrase, False if it cannot be found,
or None if an error occured.
"""
p = subprocess.Popen(["kwalletcli", "-q", "-f", folder.encode('utf-8'),

View File

@ -884,8 +884,7 @@ class Logger:
# ..., 'FEAT', feature1, feature2, ...).join(' '))
# NOTE: if there's a need to do more gzip, put that to a function
try:
data = GzipFile(fileobj=StringIO(str(data))).read().decode(
'utf-8').split('\0')
data = GzipFile(fileobj=StringIO(str(data))).read().split('\0')
except IOError:
# This data is corrupted. It probably contains non-ascii chars
to_be_removed.append((hash_method, hash_))
@ -927,7 +926,6 @@ class Logger:
# if there's a need to do more gzip, put that to a function
string = StringIO()
gzip = GzipFile(fileobj=string, mode='w')
data = data.encode('utf-8') # the gzip module can't handle unicode objects
gzip.write(data)
gzip.close()
data = string.getvalue()

View File

@ -19,7 +19,7 @@
##
import logging
import i18n
from common import i18n
def parseLogLevel(arg):
"""

View File

@ -96,7 +96,7 @@ class ConnectionArchive:
def get_item_pref(self, jid):
jid = nbxmpp.JID(jid)
if unicode(jid) in self.items:
if str(jid) in self.items:
return self.items[jid]
if jid.getStripped() in self.items:

View File

@ -87,19 +87,12 @@ class OptionsParser:
if value is None:
return
# convert to utf8 before writing to file if needed
if isinstance(value, unicode):
value = value.encode('utf-8')
else:
value = str(value)
if isinstance(opt, unicode):
opt = opt.encode('utf-8')
value = str(value)
s = ''
if parents:
if len(parents) == 1:
return
for p in parents:
if isinstance(p, unicode):
p = p.encode('utf-8')
s += p + '.'
s += opt
fd.write(s + ' = ' + value + '\n')

View File

@ -163,7 +163,7 @@ class ConnectionBytestream:
session.approve_content('file', content.name)
return
iq = nbxmpp.Iq(to=unicode(file_props.sender), typ='result')
iq = nbxmpp.Iq(to=file_props.sender, typ='result')
iq.setAttr('id', file_props.request_id)
si = iq.setTag('si', namespace=nbxmpp.NS_SI)
if file_props.offset:
@ -195,7 +195,7 @@ class ConnectionBytestream:
jingle = self._sessions[file_props.sid]
jingle.cancel_session()
return
iq = nbxmpp.Iq(to=unicode(file_props.sender), typ='error')
iq = nbxmpp.Iq(to=file_props.sender, typ='error')
iq.setAttr('id', file_props.request_id)
if code == '400' and typ in ('stream', 'profile'):
name = 'bad-request'
@ -296,7 +296,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
for file_props in FilesProp.getAllFileProp():
if is_transfer_stopped(file_props):
continue
receiver_jid = unicode(file_props.receiver)
receiver_jid = file_props.receiver
if contact.get_full_jid() == receiver_jid:
file_props.error = -5
self.remove_transfer(file_props)
@ -305,7 +305,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
gajim.nec.push_incoming_event(FileRequestErrorEvent(None,
conn=self, jid=contact.jid, file_props=file_props,
error_msg=''))
sender_jid = unicode(file_props.sender)
sender_jid = file_props.sender
if contact.get_full_jid() == sender_jid:
file_props.error = -3
self.remove_transfer(file_props)
@ -354,11 +354,11 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
file_props.error = -5
from common.connection_handlers_events import FileRequestErrorEvent
gajim.nec.push_incoming_event(FileRequestErrorEvent(None, conn=self,
jid=unicode(receiver), file_props=file_props, error_msg=''))
self._connect_error(unicode(receiver), file_props.sid,
jid=receiver, file_props=file_props, error_msg=''))
self._connect_error(receiver, file_props.sid,
file_props.sid, code=406)
else:
iq = nbxmpp.Iq(to=unicode(receiver), typ='set')
iq = nbxmpp.Iq(to=receiver, typ='set')
file_props.request_id = 'id_' + file_props.sid
iq.setID(file_props.request_id)
query = iq.setTag('query', namespace=nbxmpp.NS_BYTESTREAM)
@ -374,7 +374,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
for host in hosts:
streamhost = nbxmpp.Node(tag='streamhost')
query.addChild(node=streamhost)
streamhost.setAttr('port', unicode(port))
streamhost.setAttr('port', str(port))
streamhost.setAttr('host', host)
streamhost.setAttr('jid', sender)
@ -489,8 +489,8 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
def _add_proxy_streamhosts_to_query(self, query, file_props):
proxyhosts = self._get_file_transfer_proxies_from_config(file_props)
if proxyhosts:
file_props.proxy_receiver = unicode(file_props.receiver)
file_props.proxy_sender = unicode(file_props.sender)
file_props.proxy_receiver = file_props.receiver
file_props.proxy_sender = file_props.sender
file_props.proxyhosts = proxyhosts
for proxyhost in proxyhosts:
@ -518,12 +518,12 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
continue
host_dict = {
'state': 0,
'target': unicode(file_props.receiver),
'target': file_props.receiver,
'id': file_props.sid,
'sid': file_props.sid,
'initiator': proxy,
'host': host,
'port': unicode(_port),
'port': str(_port),
'jid': jid
}
proxyhost_dicts.append(host_dict)
@ -563,7 +563,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
iq = nbxmpp.Iq(to=to, typ='error')
iq.setAttr('id', file_props.sid)
err = iq.setTag('error')
err.setAttr('code', unicode(code))
err.setAttr('code', str(code))
err.setData(msg)
self.connection.send(iq)
if code == 404:
@ -593,7 +593,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
# register xmpppy handlers for bytestream and FT stanzas
def _bytestreamErrorCB(self, con, iq_obj):
id_ = unicode(iq_obj.getAttr('id'))
id_ = iq_obj.getAttr('id')
frm = helpers.get_full_jid_from_iq(iq_obj)
query = iq_obj.getTag('query')
gajim.proxy65_manager.error_cb(frm, query)
@ -609,10 +609,10 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
raise nbxmpp.NodeProcessed
def _bytestreamSetCB(self, con, iq_obj):
target = unicode(iq_obj.getAttr('to'))
id_ = unicode(iq_obj.getAttr('id'))
target = iq_obj.getAttr('to')
id_ = iq_obj.getAttr('id')
query = iq_obj.getTag('query')
sid = unicode(query.getAttr('sid'))
sid = query.getAttr('sid')
file_props = FilesProp.getFileProp(self.name, sid)
streamhosts = []
for item in query.getChildren():
@ -657,7 +657,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
def _ResultCB(self, con, iq_obj):
# if we want to respect xep-0065 we have to check for proxy
# activation result in any result iq
real_id = unicode(iq_obj.getAttr('id'))
real_id = iq_obj.getAttr('id')
if not real_id.startswith('au_'):
return
frm = self._ft_get_from(iq_obj)
@ -671,7 +671,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
def _bytestreamResultCB(self, con, iq_obj):
frm = self._ft_get_from(iq_obj)
real_id = unicode(iq_obj.getAttr('id'))
real_id = iq_obj.getAttr('id')
query = iq_obj.getTag('query')
gajim.proxy65_manager.resolve_result(frm, query)
@ -692,7 +692,7 @@ class ConnectionSocks5Bytestream(ConnectionBytestream):
raise nbxmpp.NodeProcessed
for host in file_props.proxyhosts:
if host['initiator'] == frm and \
unicode(query.getAttr('sid')) == file_props.sid:
query.getAttr('sid') == file_props.sid:
gajim.socks5queue.activate_proxy(host['idx'])
break
raise nbxmpp.NodeProcessed
@ -983,7 +983,7 @@ class ConnectionIBBytestream(ConnectionBytestream):
class ConnectionSocks5BytestreamZeroconf(ConnectionSocks5Bytestream):
def _ft_get_from(self, iq_obj):
return unicode(iq_obj.getFrom())
return iq_obj.getFrom()
def _ft_get_our_jid(self):
return gajim.get_jid_from_account(self.name)

View File

@ -117,7 +117,7 @@ class ProxyResolver:
"""
self.host = str(host)
self.port = int(port)
self.jid = unicode(jid)
self.jid = str(jid)
if not self.testit:
self.state = S_FINISHED
return

View File

@ -418,19 +418,12 @@ class P2PConnection(IdleObject, PlugIn):
"""
Append stanza to the queue of messages to be send if now is False, else
send it instantly
If supplied data is unicode string, encode it to UTF-8.
"""
if self.state <= 0:
return
r = packet
if isinstance(r, unicode):
r = r.encode('utf-8')
elif not isinstance(r, str):
r = ustr(r).encode('utf-8')
if now:
self.sendqueue.insert(0, (r, is_message))
self._do_send()
@ -737,7 +730,7 @@ class ClientZeroconf:
def send(self, stanza, is_message=False, now=False, on_ok=None,
on_not_ok=None):
stanza.setFrom(self.roster.zeroconf.name)
to = unicode(stanza.getTo())
to = stanza.getTo()
to = gajim.get_jid_without_resource(to)
try:
@ -802,7 +795,7 @@ class ClientZeroconf:
def on_ok(_waitid):
# if timeout:
# self._owner.set_timeout(timeout)
to = unicode(stanza.getTo())
to = stanza.getTo()
to = gajim.get_jid_without_resource(to)
try:

View File

@ -91,7 +91,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
'is_zeroconf', True)
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME,
'use_ft_proxies', False)
self.host = unicode(socket.gethostname(), locale.getpreferredencoding())
self.host = socket.gethostname()
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'hostname',
self.host)
self.port = gajim.config.get_per('accounts', gajim.ZEROCONF_ACC_NAME,
@ -110,8 +110,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
'zeroconf_email')
if not self.username:
self.username = unicode(getpass.getuser(),
locale.getpreferredencoding())
self.username = getpass.getuser()
gajim.config.set_per('accounts', gajim.ZEROCONF_ACC_NAME, 'name',
self.username)
else:
@ -427,7 +426,7 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf):
if realm == '':
if event == nbxmpp.transports_nb.DATA_ERROR:
thread_id = data[1]
frm = unicode(data[0])
frm = data[0]
session = self.get_or_create_session(frm, thread_id)
gajim.nec.push_incoming_event(MessageErrorEvent(
None, conn=self, fjid=frm, error_code=-1, error_msg=_(

View File

@ -224,14 +224,7 @@ class Zeroconf:
return show
def avahi_txt(self):
utf8_dict = {}
for key in self.txt:
val = self.txt[key]
if isinstance(val, unicode):
utf8_dict[key] = val.encode('utf-8')
else:
utf8_dict[key] = val
return self.avahi.dict_to_txt_array(utf8_dict)
return self.avahi.dict_to_txt_array(self.txt)
def create_service(self):
try:

View File

@ -1355,11 +1355,11 @@ class ManageProxiesWindow:
model = self.proxies_treeview.get_model()
proxies = gajim.config.get_per('proxies')
i = 1
while ('proxy' + unicode(i)) in proxies:
while ('proxy' + str(i)) in proxies:
i += 1
iter_ = model.append()
model.set(iter_, 0, 'proxy' + unicode(i))
gajim.config.add_per('proxies', 'proxy' + unicode(i))
model.set(iter_, 0, 'proxy' + str(i))
gajim.config.add_per('proxies', 'proxy' + str(i))
self.proxies_treeview.set_cursor(model.get_path(iter_))
def on_remove_proxy_button_clicked(self, widget):
@ -1453,7 +1453,7 @@ class ManageProxiesWindow:
self.xml.get_object('proxy_table').set_sensitive(True)
proxyhost_entry.set_text(gajim.config.get_per('proxies', proxy,
'host'))
proxyport_entry.set_text(unicode(gajim.config.get_per('proxies',
proxyport_entry.set_text(str(gajim.config.get_per('proxies',
proxy, 'port')))
proxyuser_entry.set_text(gajim.config.get_per('proxies', proxy,
'user'))
@ -1955,7 +1955,7 @@ class AccountsWindow:
if not custom_port:
custom_port = 5222
gajim.config.set_per('accounts', account, 'custom_port', custom_port)
self.xml.get_object('custom_port_entry1').set_text(unicode(custom_port))
self.xml.get_object('custom_port_entry1').set_text(str(custom_port))
# Personal tab
gpg_key_label = self.xml.get_object('gpg_key_label1')
@ -3288,13 +3288,13 @@ class ManageBookmarksWindow:
return
for account in self.treestore:
account_unicode = account[1]
gajim.connections[account_unicode].bookmarks = []
acct = account[1]
gajim.connections[acct].bookmarks = []
for bm in account.iterchildren():
# Convert True/False/None to '1' or '0'
autojoin = unicode(int(bm[3]))
minimize = unicode(int(bm[4]))
autojoin = str(int(bm[3]))
minimize = str(int(bm[4]))
name = bm[1]
jid = bm[2]
pw = bm[5]
@ -3305,9 +3305,9 @@ class ManageBookmarksWindow:
'minimize': minimize, 'password': pw, 'nick': nick,
'print_status': bm[7]}
gajim.connections[account_unicode].bookmarks.append(bmdict)
gajim.connections[acct].bookmarks.append(bmdict)
gajim.connections[account_unicode].store_bookmarks()
gajim.connections[acct].store_bookmarks()
gajim.interface.roster.set_actions_menu_needs_rebuild()
self.window.destroy()

View File

@ -1313,10 +1313,6 @@ class ConversationTextview(GObject.GObject):
timestamp_str = helpers.from_one_line(timestamp_str)
format_ += timestamp_str
tim_format = time.strftime(format_, tim)
if locale.getpreferredencoding() not in ('KOI8-R', 'cp1251'):
# if tim_format comes as unicode because of day_str.
# we convert it to the encoding that we want (and that is utf-8)
tim_format = helpers.ensure_utf8_string(tim_format)
return tim_format
def detect_other_text_tag(self, text, kind):

View File

@ -113,7 +113,7 @@ class DataFormWidget(Gtk.Alignment, object):
def get_title(self):
"""
Get the title of data form, as a unicode object. If no title or no form,
Get the title of data form. If no title or no form,
returns ''. Useful for setting window title
"""
if self._data_form is not None:

View File

@ -3110,7 +3110,7 @@ class SingleMessageWindow:
def update_char_counter(self, widget):
characters_no = self.message_tv_buffer.get_char_count()
self.count_chars_label.set_text(unicode(characters_no))
self.count_chars_label.set_text(characters_no)
def send_single_message(self):
if gajim.connections[self.account].connected <= 1:

View File

@ -153,12 +153,12 @@ class FileTransfersWindow:
for file_props in allfp:
if file_props.type_ == 's' and file_props.tt_account == account:
# 'account' is the sender
receiver_jid = unicode(file_props.receiver).split('/')[0]
receiver_jid = file_props.receiver.split('/')[0]
if jid == receiver_jid and not is_transfer_stopped(file_props):
active_transfers[0].append(file_props)
elif file_props.type_ == 'r' and file_props.tt_account == account:
# 'account' is the recipient
sender_jid = unicode(file_props.sender).split('/')[0]
sender_jid = file_props.sender.split('/')[0]
if jid == sender_jid and not is_transfer_stopped(file_props):
active_transfers[1].append(file_props)
else:
@ -188,7 +188,7 @@ class FileTransfersWindow:
sectext += '\n\t' + _('Size: %s') % \
helpers.convert_bytes(file_props.size)
if file_props.type_ == 'r':
jid = unicode(file_props.sender).split('/')[0]
jid = file_props.sender.split('/')[0]
sender_name = gajim.contacts.get_first_contact_from_jid(
file_props.tt_account, jid).get_shown_name()
sender = sender_name
@ -198,7 +198,7 @@ class FileTransfersWindow:
sectext += '\n\t' + _('Sender: %s') % sender
sectext += '\n\t' + _('Recipient: ')
if file_props.type_ == 's':
jid = unicode(file_props.receiver).split('/')[0]
jid = file_props.receiver.split('/')[0]
receiver_name = gajim.contacts.get_first_contact_from_jid(
file_props.tt_account, jid).get_shown_name()
recipient = receiver_name
@ -533,7 +533,7 @@ class FileTransfersWindow:
_str += ' '
if percent < 10:
_str += ' '
_str += unicode(percent) + '% \n'
_str += str(percent) + '% \n'
return _str
def _format_time(self, _time):
@ -585,7 +585,7 @@ class FileTransfersWindow:
other = file_props.sender
else: # we send a file
other = file_props.receiver
if isinstance(other, unicode):
if isinstance(other, str):
jid = gajim.get_jid_without_resource(other)
else: # It's a Contact instance
jid = other.jid
@ -713,7 +713,7 @@ class FileTransfersWindow:
file_props.type_ = 's'
file_props.desc = file_desc
file_props.elapsed_time = 0
file_props.size = unicode(stat[6])
file_props.size = str(stat[6])
file_props.sender = account
file_props.receiver = contact
file_props.tt_account = account

View File

@ -354,10 +354,7 @@ class GajimRemote:
elif self.command == 'list_accounts':
if isinstance(res, list):
for account in res:
if isinstance(account, unicode):
print(account.encode(PREFERRED_ENCODING))
else:
print(account)
print(account)
elif self.command == 'account_info':
if res:
print(self.print_info(0, res, True))
@ -368,14 +365,11 @@ class GajimRemote:
pref_keys = sorted(res.keys())
for pref_key in pref_keys:
result = '%s = %s' % (pref_key, res[pref_key])
if isinstance(result, unicode):
print(result.encode(PREFERRED_ENCODING))
else:
print(result)
print(result)
elif self.command == 'contact_info':
print(self.print_info(0, res, True))
elif res:
print(unicode(res).encode(PREFERRED_ENCODING))
print(res)
def check_gajim_running(self):
if not self.sbus:
@ -470,7 +464,7 @@ class GajimRemote:
ret_str +='\t'
elif isinstance(val, int):
ret_str +='\t' + str(val)
elif isinstance(val, (str, unicode)):
elif isinstance(val, str):
ret_str +='\t' + val
elif isinstance(val, (list, tuple)):
res = ''
@ -485,7 +479,7 @@ class GajimRemote:
for key in prop_dict.keys():
val = prop_dict[key]
spacing = ' ' * level * 4
if isinstance(val, (unicode, int, str)):
if isinstance(val, (int, str)):
if val is not None:
val = val.strip()
ret_str += '%s%-10s: %s\n' % (spacing, key, val)

View File

@ -84,7 +84,7 @@ if os.name == 'nt':
os.environ['LANG'] = lang
gettext.bindtextdomain(APP, DIR)
gettext.textdomain(APP)
gettext.install(APP, DIR, unicode=True)
gettext.install(APP, DIR)
locale.setlocale(locale.LC_ALL, '')
import ctypes
@ -155,12 +155,8 @@ def parseOpts():
import locale
profile, config_path = parseOpts()
if config_path:
config_path = unicode(config_path, locale.getpreferredencoding())
del parseOpts
profile = unicode(profile, locale.getpreferredencoding())
import common.configpaths
common.configpaths.gajimpaths.init(config_path)
del config_path

View File

@ -168,10 +168,10 @@ class GajimThemesWindow:
# don't confuse translators
theme_name = _('theme name')
theme_name_ns = theme_name.replace(' ', '_')
while theme_name_ns + unicode(i) in gajim.config.get_per('themes'):
while theme_name_ns + str(i) in gajim.config.get_per('themes'):
i += 1
model.set_value(iter_, 0, theme_name + unicode(i))
gajim.config.add_per('themes', theme_name_ns + unicode(i))
model.set_value(iter_, 0, theme_name + str(i))
gajim.config.add_per('themes', theme_name_ns + str(i))
self.themes_tree.get_selection().select_iter(iter_)
col = self.themes_tree.get_column(0)
path = model.get_path(iter_)

View File

@ -687,7 +687,7 @@ class GroupchatControl(ChatControlBase):
if num_unread == 1:
unread = '*'
elif num_unread > 1:
unread = '[' + unicode(num_unread) + ']'
unread = '[' + str(num_unread) + ']'
label_str = unread + label_str
return (label_str, color)
@ -1048,9 +1048,7 @@ class GroupchatControl(ChatControlBase):
return None
def print_old_conversation(self, text, contact='', tim=None, xhtml = None,
displaymarking=None):
if isinstance(text, str):
text = unicode(text, 'utf-8')
displaymarking=None):
if contact:
if contact == self.nick: # it's us
kind = 'outgoing'
@ -1076,8 +1074,6 @@ class GroupchatControl(ChatControlBase):
(contact = 'info' in such a case).
If contact is not set: it's a message from the server or help.
"""
if isinstance(text, str):
text = unicode(text, 'utf-8')
other_tags_for_name = []
other_tags_for_text = []
if contact:
@ -2200,7 +2196,7 @@ class GroupchatControl(ChatControlBase):
self.nick_hits = [] # clear the hit list
list_nick = gajim.contacts.get_nick_list(self.account,
self.room_jid)
list_nick.sort(key=unicode.lower) # case-insensitive sort
list_nick.sort(key=str.lower) # case-insensitive sort
if begin == '':
# empty message, show lasts nicks that highlighted us first
for nick in self.attention_list:

View File

@ -164,7 +164,7 @@ class Interface:
def handle_event_iq_error(self, obj):
#('ERROR_ANSWER', account, (id_, fjid, errmsg, errcode))
if unicode(obj.errcode) in ('400', '403', '406') and obj.id_:
if str(obj.errcode) in ('400', '403', '406') and obj.id_:
# show the error dialog
ft = self.instances['file_transfers']
sid = obj.id_
@ -172,7 +172,7 @@ class Interface:
sid = obj.id_[3:]
file_props = FilesProp.getFileProp(obj.conn.name, sid)
if file_props :
if unicode(obj.errcode) == '400':
if str(obj.errcode) == '400':
file_props.error = -3
else:
file_props.error = -4
@ -181,7 +181,7 @@ class Interface:
error_msg=obj.errmsg))
obj.conn.disconnect_transfer(file_props)
return
elif unicode(obj.errcode) == '404':
elif str(obj.errcode) == '404':
sid = obj.id_
if len(obj.id_) > 3 and obj.id_[2] == '_':
sid = obj.id_[3:]
@ -951,7 +951,7 @@ class Interface:
ft_win = self.instances['file_transfers']
if not file_props.hash_:
# We disn't get the hash, sender probably don't support that
jid = unicode(file_props.sender)
jid = file_props.sender
self.popup_ft_result(account, jid, file_props)
ft_win.set_status(file_props, 'ok')
h = Hashes()
@ -963,7 +963,7 @@ class Interface:
file_.close()
# If the hash we received and the hash of the file are the same,
# then the file is not corrupt
jid = unicode(file_props.sender)
jid = file_props.sender
if file_props.hash_ == hash_:
GObject.idle_add(self.popup_ft_result, account, jid, file_props)
GObject.idle_add(ft_win.set_status, file_props, 'ok')
@ -995,7 +995,7 @@ class Interface:
self.hashThread.start()
gajim.socks5queue.remove_receiver(file_props.sid, True, True)
else: # we send a file
jid = unicode(file_props.receiver)
jid = file_props.receiver
gajim.socks5queue.remove_sender(file_props.sid, True, True)
self.popup_ft_result(account, jid, file_props)
@ -1042,7 +1042,7 @@ class Interface:
if file_props is not None:
if file_props.type_ == 'r':
# get the name of the sender, as it is in the roster
sender = unicode(file_props.sender).split('/')[0]
sender = file_props.sender.split('/')[0]
name = gajim.contacts.get_first_contact_from_jid(account,
sender).get_shown_name()
filename = os.path.basename(file_props.file_name)

View File

@ -498,7 +498,7 @@ class MessageWindow(object):
unread_str = ''
if unread > 1:
unread_str = '[' + unicode(unread) + '] '
unread_str = '[' + str(unread) + '] '
elif unread == 1:
unread_str = '* '
else:
@ -693,10 +693,8 @@ class MessageWindow(object):
Return the MessageControl for jid or n, where n is a notebook page index.
When key is an int index acct may be None
"""
if isinstance(key, str):
key = unicode(key, 'utf-8')
if isinstance(key, unicode):
if isinstance(key, str):
jid = key
try:
return self._controls[acct][jid]

View File

@ -46,7 +46,7 @@ class GajimPlugin(object):
Will be shown in plugins management GUI.
:type: unicode
:type: str
'''
short_name = ''
'''
@ -54,7 +54,7 @@ class GajimPlugin(object):
Used for quick indentification of plugin.
:type: unicode
:type: str
:todo: decide whether we really need this one, because class name (with
module name) can act as such short name
@ -63,7 +63,7 @@ class GajimPlugin(object):
'''
Version of plugin.
:type: unicode
:type: str
:todo: decide how to compare version between each other (which one
is higher). Also rethink: do we really need to compare versions
@ -75,7 +75,7 @@ class GajimPlugin(object):
'''
Plugin description.
:type: unicode
:type: str
:todo: should be allow rich text here (like HTML or reStructuredText)?
'''
@ -83,7 +83,7 @@ class GajimPlugin(object):
'''
Plugin authors.
:type: [] of unicode
:type: [] of str
:todo: should we decide on any particular format of author strings?
Especially: should we force format of giving author's e-mail?
@ -92,7 +92,7 @@ class GajimPlugin(object):
'''
URL to plug-in's homepage.
:type: unicode
:type: str
:todo: should we check whether provided string is valid URI? (Maybe
using 'property')
@ -120,7 +120,7 @@ class GajimPlugin(object):
Values are tuples: (default_value, option_description). The first one can
be anything (this is the advantage of using shelve/pickle instead of
custom-made config I/O handling); the second one should be unicode (gettext
custom-made config I/O handling); the second one should be str (gettext
can be used if need and/or translation is planned).
:type: {} of 2-element tuples

View File

@ -158,7 +158,7 @@ class PluginManager(object):
active yet).
:param gui_extpoint_name: name of GUI extension point.
:type gui_extpoint_name: unicode
:type gui_extpoint_name: str
:param args: parameters to be passed to extension point handlers
(typically and object that invokes `gui_extension_point`;
however, this can be practically anything)
@ -209,7 +209,7 @@ class PluginManager(object):
freedom, but is this necessary?
:param gui_extpoint_name: name of GUI extension point.
:type gui_extpoint_name: unicode
:type gui_extpoint_name: str
:param args: arguments that `PluginManager.gui_extension_point` was
called with for this extension point. This is used (along with
extension point name) to identify element to be removed.
@ -394,7 +394,7 @@ class PluginManager(object):
Scans given directory for plugin classes.
:param path: directory to scan for plugins
:type path: unicode
:type path: str
:return: list of found plugin classes (subclasses of `GajimPlugin`
:rtype: [] of class objects

View File

@ -72,7 +72,7 @@ def get_dbus_struct(obj):
"""
if obj is None:
return DBUS_NONE()
if isinstance(obj, (unicode, str)):
if isinstance(obj, str):
return DBUS_STRING(obj)
if isinstance(obj, int):
return DBUS_INT32(obj)
@ -613,8 +613,8 @@ class SignalObject(dbus.service.Object):
"""
Get vcard info for a contact. Return cached value of the vcard
"""
if not isinstance(jid, unicode):
jid = unicode(jid)
if not isinstance(jid, str):
jid = str(jid)
if not jid:
raise dbus_support.MissingArgument()
jid = self._get_real_jid(jid)
@ -652,9 +652,9 @@ class SignalObject(dbus.service.Object):
result['name'] = DBUS_STRING(con.name)
result['jid'] = DBUS_STRING(gajim.get_jid_from_account(con.name))
result['message'] = DBUS_STRING(con.status)
result['priority'] = DBUS_STRING(unicode(con.priority))
result['resource'] = DBUS_STRING(unicode(gajim.config.get_per(
'accounts', con.name, 'resource')))
result['priority'] = DBUS_STRING(str(con.priority))
result['resource'] = DBUS_STRING(gajim.config.get_per('accounts',
con.name, 'resource'))
return result
@dbus.service.method(INTERFACE, in_signature='s', out_signature='aa{sv}')

View File

@ -1202,7 +1202,7 @@ class RosterWindow:
nb_connected_contact += 1
if nb_connected_contact > 1:
# switch back to default writing direction
name += i18n.paragraph_direction_mark(unicode(name))
name += i18n.paragraph_direction_mark(name)
name += ' (%d)' % nb_connected_contact
# add status msg, if not empty, under contact name in
@ -3512,8 +3512,8 @@ class RosterWindow:
elif type_ == 'agent':
self.on_remove_agent(widget, list_)
elif not (event.get_state() & (Gdk.ModifierType.CONTROL_MASK | Gdk.ModifierType.MOD1_MASK)) and\
Gdk.keyval_to_unicode(event.keyval):
elif not (event.get_state() & (Gdk.ModifierType.CONTROL_MASK | \
Gdk.ModifierType.MOD1_MASK)) and Gdk.keyval_to_unicode(event.keyval):
# if we got unicode symbol without ctrl / alt
num = Gdk.keyval_to_unicode(event.keyval)
self.enable_rfilter(unichr(num))

View File

@ -235,13 +235,10 @@ class StatusTable:
self.current_row + 1)
def get_status_info(self, resource, priority, show, status):
str_status = resource + ' (' + unicode(priority) + ')'
str_status = resource + ' (' + str(priority) + ')'
if status:
status = status.strip()
if status != '':
# make sure 'status' is unicode before we send to to reduce_chars
if isinstance(status, str):
status = unicode(status, encoding='utf-8')
# reduce to 100 chars, 1 line
status = helpers.reduce_chars_newlines(status, 100, 1)
str_status = GObject.markup_escape_text(str_status)
@ -301,10 +298,6 @@ class NotificationAreaTooltip(BaseTooltip, StatusTable):
file_path = os.path.join(helpers.get_iconset_path(iconset), '16x16')
for acct in accounts:
message = acct['message']
# before reducing the chars we should assure we send unicode, else
# there are possible pango TBs on 'set_markup'
if isinstance(message, str):
message = unicode(message, encoding = 'utf-8')
message = helpers.reduce_chars_newlines(message, 100, 1)
message = GObject.markup_escape_text(message)
if acct['name'] in gajim.con_types and \
@ -606,7 +599,7 @@ class RosterTooltip(NotificationAreaTooltip):
if num_resources == 1 and contact.resource:
properties.append((_('Resource: '),
GObject.markup_escape_text(contact.resource) +\
' (' + unicode(contact.priority) + ')'))
' (' + str(contact.priority) + ')'))
if self.account and prim_contact.sub and prim_contact.sub != 'both' and\
prim_contact.jid not in gajim.gc_connected[self.account]:
@ -670,7 +663,7 @@ class RosterTooltip(NotificationAreaTooltip):
vcard_current_row + 1, Gtk.AttachOptions.EXPAND | \
Gtk.AttachOptions.FILL, vertical_fill, 0, 0)
else:
if isinstance(property_[0], (unicode, str)): # FIXME: rm unicode?
if isinstance(property_[0], str):
label.set_markup(property_[0])
label.set_line_wrap(True)
else:
@ -743,7 +736,7 @@ class FileTransfersTooltip(BaseTooltip):
if file_props.type_ == 'r':
type_ = _('Download')
actor = _('Sender: ')
sender = unicode(file_props.sender).split('/')[0]
sender = file_props.sender.split('/')[0]
name = gajim.contacts.get_first_contact_from_jid(
file_props.tt_account, sender).get_shown_name()
else:

View File

@ -408,10 +408,10 @@ class VcardWindow:
tt_text = _("There is no pending subscription request.")
eb.set_tooltip_text(tt_text)
resources = '%s (%s)' % (self.contact.resource, unicode(
self.contact.priority))
resources = '%s (%s)' % (self.contact.resource, str(
self.contact.priority))
uf_resources = self.contact.resource + _(' resource with priority ')\
+ unicode(self.contact.priority)
+ str(self.contact.priority)
if not self.contact.status:
self.contact.status = ''
@ -462,9 +462,9 @@ class VcardWindow:
for c in contact_list:
if c.resource != self.contact.resource:
resources += '\n%s (%s)' % (c.resource,
unicode(c.priority))
str(c.priority))
uf_resources += '\n' + c.resource + \
_(' resource with priority ') + unicode(c.priority)
_(' resource with priority ') + str(c.priority)
if c.show not in ('offline', 'error'):
GObject.idle_add(
gajim.connections[self.account].request_os_info, c.jid,
@ -584,10 +584,10 @@ class ZeroconfVcardWindow:
'</span></b>')
self.xml.get_object('local_jid_label').set_text(self.contact.jid)
resources = '%s (%s)' % (self.contact.resource, unicode(
self.contact.priority))
resources = '%s (%s)' % (self.contact.resource, str(
self.contact.priority))
uf_resources = self.contact.resource + _(' resource with priority ')\
+ unicode(self.contact.priority)
+ str(self.contact.priority)
if not self.contact.status:
self.contact.status = ''