Commit 414e3493 authored by Yann Leboulanger's avatar Yann Leboulanger

python uses unicode internally

parent e71188a6
......@@ -452,7 +452,7 @@ class CommandWindow:
note = command.getTag('note')
if note:
self.notes_label.set_text(note.getData().decode('utf-8'))
self.notes_label.set_text(note.getData())
self.notes_label.set_no_show_all(False)
self.notes_label.show()
else:
......@@ -510,7 +510,7 @@ class CommandWindow:
try:
errorname = nbxmpp.NS_STANZAS + ' ' + str(errorid)
errordesc = nbxmpp.ERRORS[errorname][2]
error = errordesc.decode('utf-8')
error = errordesc
del errorname, errordesc
except KeyError: # when stanza doesn't have error description
error = _('Service returned an error.')
......
......@@ -141,8 +141,7 @@ class AdvancedConfigurationWindow(object):
"""
optname = model[iter_][C_PREFNAME]
opttype = model[iter_][C_TYPE]
if opttype.decode('utf-8') == self.types['boolean'] or optname == 'password':
if opttype == self.types['boolean'] or optname == 'password':
cell.set_property('editable', False)
else:
cell.set_property('editable', True)
......@@ -153,10 +152,10 @@ class AdvancedConfigurationWindow(object):
# path[1] is the key name
# path[2] is the root of tree
# last two is optional
path = [model[iter_][0].decode('utf-8')]
path = [model[iter_][0]]
parent = model.iter_parent(iter_)
while parent:
path.append(model[parent][0].decode('utf-8'))
path.append(model[parent][0])
parent = model.iter_parent(parent)
return path
......@@ -194,17 +193,17 @@ class AdvancedConfigurationWindow(object):
def on_advanced_treeview_row_activated(self, treeview, path, column):
modelpath = self.modelfilter.convert_path_to_child_path(path)
modelrow = self.model[modelpath]
option = modelrow[0].decode('utf-8')
if modelrow[2].decode('utf-8') == self.types['boolean']:
option = modelrow[0]
if modelrow[2] == self.types['boolean']:
for key in self.right_true_dict.keys():
if self.right_true_dict[key] == modelrow[1].decode('utf-8'):
if self.right_true_dict[key] == modelrow[1]:
modelrow[1] = str(key)
newval = {'False': True, 'True': False}[modelrow[1]]
if len(modelpath.get_indices()) > 1:
optnamerow = self.model[modelpath.get_indices()[0]]
optname = optnamerow[0].decode('utf-8')
optname = optnamerow[0]
keyrow = self.model[modelpath.get_indices()[:2]]
key = keyrow[0].decode('utf-8')
key = keyrow[0]
self.remember_option(option + '\n' + key + '\n' + optname,
modelrow[1], newval)
gajim.config.set_per(optname, key, option, newval)
......@@ -234,13 +233,12 @@ class AdvancedConfigurationWindow(object):
modelpath = self.modelfilter.convert_path_to_child_path(path)
modelrow = self.model[modelpath]
modelpath = modelpath.get_indices()
option = modelrow[0].decode('utf-8')
text = text.decode('utf-8')
option = modelrow[0]
if len(modelpath) > 1:
optnamerow = self.model[modelpath[0]]
optname = optnamerow[0].decode('utf-8')
optname = optnamerow[0]
keyrow = self.model[modelpath[:2]]
key = keyrow[0].decode('utf-8')
key = keyrow[0]
self.remember_option(option + '\n' + key + '\n' + optname, modelrow[1],
text)
gajim.config.set_per(optname, key, option, text)
......@@ -269,12 +267,12 @@ class AdvancedConfigurationWindow(object):
return
modelpath = self.modelfilter.convert_path_to_child_path(path)
modelrow = self.model[modelpath]
option = modelrow[0].decode('utf-8')
option = modelrow[0]
if len(modelpath) > 1:
optnamerow = self.model[modelpath[0]]
optname = optnamerow[0].decode('utf-8')
optname = optnamerow[0]
keyrow = self.model[modelpath[:2]]
key = keyrow[0].decode('utf-8')
key = keyrow[0]
self.remember_option(option + '\n' + key + '\n' + optname,
modelrow[C_VALUE], default)
gajim.config.set_per(optname, key, option, default)
......@@ -317,7 +315,7 @@ class AdvancedConfigurationWindow(object):
self.model.append(parent, [name, value, type_])
def visible_func(self, model, treeiter, data):
search_string = self.entry.get_text().decode('utf-8').lower()
search_string = self.entry.get_text().lower()
for it in tree_model_pre_order(model, treeiter):
if model[it][C_TYPE] != '':
opt_path = self.get_option_path(model, it)
......
......@@ -84,20 +84,20 @@ class AtomWindow:
# fill the fields
if newentry.feed_link is not None:
self.feed_title_label.set_markup(
u'<span foreground="blue" underline="single">%s</span>' % \
'<span foreground="blue" underline="single">%s</span>' % \
GObject.markup_escape_text(newentry.feed_title))
else:
self.feed_title_label.set_markup(
GObject.markup_escape_text(newentry.feed_title))
self.feed_tagline_label.set_markup(
u'<small>%s</small>' % \
'<small>%s</small>' % \
GObject.markup_escape_text(newentry.feed_tagline))
if newentry.title:
if newentry.uri is not None:
self.entry_title_label.set_markup(
u'<span foreground="blue" underline="single">%s</span>' % \
'<span foreground="blue" underline="single">%s</span>' % \
GObject.markup_escape_text(newentry.title))
else:
self.entry_title_label.set_markup(
......
......@@ -620,7 +620,7 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
message_buffer = self.msg_textview.get_buffer()
start_iter = message_buffer.get_start_iter()
end_iter = message_buffer.get_end_iter()
message = message_buffer.get_text(start_iter, end_iter, False).decode('utf-8')
message = message_buffer.get_text(start_iter, end_iter, False)
xhtml = self.msg_textview.get_xhtml()
# send the message
......@@ -2842,7 +2842,7 @@ class ChatControl(ChatControlBase):
type_ = model[iter_][2]
if type_ != 'contact': # source is not a contact
return
dropped_jid = data.decode('utf-8')
dropped_jid = data
dropped_transport = gajim.get_transport_name_from_jid(dropped_jid)
c_transport = gajim.get_transport_name_from_jid(c.jid)
......
......@@ -100,13 +100,13 @@ class OldEntry(nbxmpp.Node, object):
if main_feed is not None and source_feed is not None:
return u'%s: %s' % (main_feed, source_feed)
return '%s: %s' % (main_feed, source_feed)
elif main_feed is not None:
return main_feed
elif source_feed is not None:
return source_feed
else:
return u''
return ''
feed_title = property(get_feed_title, None, None,
''' Title of feed. It is built from entry''s original feed title and title of feed
......@@ -173,4 +173,4 @@ class OldEntry(nbxmpp.Node, object):
updated = property(get_updated, None, None,
''' Last significant modification time. ''')
feed_tagline = u''
feed_tagline = ''
......@@ -133,11 +133,11 @@ def split_db():
try:
import configpaths
OLD_LOG_DB_FOLDER = os.path.join(configpaths.fse(
os.environ[u'appdata']), u'Gajim')
os.environ['appdata']), 'Gajim')
except KeyError:
OLD_LOG_DB_FOLDER = u'.'
OLD_LOG_DB_FOLDER = '.'
else:
OLD_LOG_DB_FOLDER = os.path.expanduser(u'~/.gajim')
OLD_LOG_DB_FOLDER = os.path.expanduser('~/.gajim')
tmp = logger.CACHE_DB_PATH
logger.CACHE_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, 'cache.db')
......@@ -148,7 +148,7 @@ def split_db():
os.chdir(back)
cur = con.cursor()
cur.execute('''SELECT name FROM sqlite_master WHERE type = 'table';''')
tables = cur.fetchall() # we get [(u'jids',), (u'unread_messages',), ...
tables = cur.fetchall() # we get [('jids',), ('unread_messages',), ...
tables = [t[0] for t in tables]
cur.execute("ATTACH DATABASE '%s' AS cache" % logger.CACHE_DB_PATH)
for table in ('caps_cache', 'rooms_last_message_time', 'roster_entry',
......@@ -189,22 +189,22 @@ def check_and_possibly_move_config():
if os.name == 'nt':
try:
OLD_LOG_DB_FOLDER = os.path.join(configpaths.fse(
os.environ[u'appdata']), u'Gajim')
os.environ['appdata']), 'Gajim')
except KeyError:
OLD_LOG_DB_FOLDER = u'.'
OLD_LOG_DB_FOLDER = '.'
else:
OLD_LOG_DB_FOLDER = os.path.expanduser(u'~/.gajim')
OLD_LOG_DB_FOLDER = os.path.expanduser('~/.gajim')
if not os.path.exists(OLD_LOG_DB_FOLDER):
return
OLD_LOG_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, u'logs.db')
OLD_CACHE_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, u'cache.db')
vars['OLD_VCARD_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'vcards')
vars['OLD_AVATAR_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'avatars')
vars['OLD_MY_EMOTS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'emoticons')
vars['OLD_MY_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'iconsets')
vars['OLD_MY_MOOD_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, u'moods')
OLD_LOG_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, 'logs.db')
OLD_CACHE_DB_PATH = os.path.join(OLD_LOG_DB_FOLDER, 'cache.db')
vars['OLD_VCARD_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'vcards')
vars['OLD_AVATAR_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'avatars')
vars['OLD_MY_EMOTS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'emoticons')
vars['OLD_MY_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'iconsets')
vars['OLD_MY_MOOD_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER, 'moods')
vars['OLD_MY_ACTIVITY_ICONSETS_PATH'] = os.path.join(OLD_LOG_DB_FOLDER,
u'activities')
'activities')
OLD_CONFIG_FILES = []
OLD_DATA_FILES = []
for f in os.listdir(OLD_LOG_DB_FOLDER):
......@@ -345,7 +345,7 @@ def check_and_possibly_create_paths():
print(_('%s is a directory but should be a file') % CACHE_DB_PATH)
print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(XTLS_CERTS):
create_path(XTLS_CERTS)
if not os.path.exists(LOCAL_XTLS_CERTS):
......
......@@ -104,12 +104,12 @@ class ChangeStatusCommand(AdHocCommand):
var = 'presence-type',
label = 'Type of presence:',
options = [
(u'chat', _('Free for chat')),
(u'online', _('Online')),
(u'away', _('Away')),
(u'xa', _('Extended away')),
(u'dnd', _('Do not disturb')),
(u'offline', _('Offline - disconnect'))],
('chat', _('Free for chat')),
('online', _('Online')),
('away', _('Away')),
('xa', _('Extended away')),
('dnd', _('Do not disturb')),
('offline', _('Offline - disconnect'))],
value = 'online',
required = True),
dataforms.Field('text-multi',
......@@ -146,7 +146,7 @@ class ChangeStatusCommand(AdHocCommand):
try:
presencedesc = form['presence-desc'].value
except Exception: # same exceptions as in last comment
presencedesc = u''
presencedesc = ''
response, cmd = self.buildResponse(request, status = 'completed')
cmd.addChild('note', {}, _('The status has been changed.'))
......@@ -197,7 +197,7 @@ class LeaveGroupchatsCommand(AdHocCommand):
options = []
account = self.connection.name
for gc in find_current_groupchats(account):
options.append((u'%s' %(gc[0]), _('%(nickname)s on %(room_jid)s') % \
options.append(('%s' %(gc[0]), _('%(nickname)s on %(room_jid)s') % \
{'nickname': gc[1], 'room_jid': gc[0]}))
if not len(options):
response, cmd = self.buildResponse(request, status = 'completed')
......@@ -367,7 +367,7 @@ class ConnectionCommands:
if cmd.isVisibleFor(self.isSameJID(jid)):
q.addChild('item', {
# TODO: find the jid
'jid': self.getOurBareJID() + u'/' + self.server_resource,
'jid': self.getOurBareJID() + '/' + self.server_resource,
'node': node,
'name': cmd.commandname})
......
......@@ -82,10 +82,10 @@ class ConfigPaths:
# variable 'appdata' is in? Assuming it to be in filesystem
# encoding.
self.config_root = self.cache_root = self.data_root = \
os.path.join(fse(os.environ[u'appdata']), u'Gajim')
os.path.join(fse(os.environ['appdata']), 'Gajim')
except KeyError:
# win9x, in cwd
self.config_root = self.cache_root = self.data_root = u'.'
self.config_root = self.cache_root = self.data_root = '.'
else: # Unices
# Pass in an Unicode string, and hopefully get one back.
if HAVE_XDG:
......@@ -93,23 +93,23 @@ class ConfigPaths:
if not self.config_root:
# Folder doesn't exist yet.
self.config_root = os.path.join(xdg.BaseDirectory.\
xdg_config_dirs[0], u'gajim')
xdg_config_dirs[0], 'gajim')
self.cache_root = os.path.join(xdg.BaseDirectory.xdg_cache_home,
u'gajim')
'gajim')
self.data_root = xdg.BaseDirectory.save_data_path('gajim')
if not self.data_root:
self.data_root = os.path.join(xdg.BaseDirectory.\
xdg_data_dirs[0], u'gajim')
xdg_data_dirs[0], 'gajim')
else:
expand = os.path.expanduser
base = os.getenv('XDG_CONFIG_HOME') or expand(u'~/.config')
self.config_root = os.path.join(base, u'gajim')
base = os.getenv('XDG_CACHE_HOME') or expand(u'~/.cache')
self.cache_root = os.path.join(base, u'gajim')
base = os.getenv('XDG_DATA_HOME') or expand(u'~/.local/share')
self.data_root = os.path.join(base, u'gajim')
base = os.getenv('XDG_CONFIG_HOME') or expand('~/.config')
self.config_root = os.path.join(base, 'gajim')
base = os.getenv('XDG_CACHE_HOME') or expand('~/.cache')
self.cache_root = os.path.join(base, 'gajim')
base = os.getenv('XDG_DATA_HOME') or expand('~/.local/share')
self.data_root = os.path.join(base, 'gajim')
def add(self, name, type_, path):
self.paths[name] = (type_, path)
......@@ -138,27 +138,27 @@ class ConfigPaths:
if root is not None:
self.config_root = self.cache_root = self.data_root = root
d = {'MY_DATA': '', 'LOG_DB': u'logs.db', 'MY_CACERTS': u'cacerts.pem',
'MY_EMOTS': u'emoticons', 'MY_ICONSETS': u'iconsets',
'MY_MOOD_ICONSETS': u'moods', 'MY_ACTIVITY_ICONSETS': u'activities',
'PLUGINS_USER': u'plugins', 'MY_PEER_CERTS': u'certs'}
d = {'MY_DATA': '', 'LOG_DB': 'logs.db', 'MY_CACERTS': 'cacerts.pem',
'MY_EMOTS': 'emoticons', 'MY_ICONSETS': 'iconsets',
'MY_MOOD_ICONSETS': 'moods', 'MY_ACTIVITY_ICONSETS': 'activities',
'PLUGINS_USER': 'plugins', 'MY_PEER_CERTS': 'certs'}
for name in d:
self.add(name, TYPE_DATA, windowsify(d[name]))
d = {'MY_CACHE': '', 'CACHE_DB': u'cache.db', 'VCARD': u'vcards',
'AVATAR': u'avatars'}
d = {'MY_CACHE': '', 'CACHE_DB': 'cache.db', 'VCARD': 'vcards',
'AVATAR': 'avatars'}
for name in d:
self.add(name, TYPE_CACHE, windowsify(d[name]))
self.add('MY_CONFIG', TYPE_CONFIG, '')
self.add('MY_CERT', TYPE_CONFIG, '')
basedir = fse(os.environ.get(u'GAJIM_BASEDIR', defs.basedir))
self.add('DATA', None, os.path.join(basedir, windowsify(u'data')))
self.add('ICONS', None, os.path.join(basedir, windowsify(u'icons')))
basedir = fse(os.environ.get('GAJIM_BASEDIR', defs.basedir))
self.add('DATA', None, os.path.join(basedir, windowsify('data')))
self.add('ICONS', None, os.path.join(basedir, windowsify('icons')))
self.add('HOME', None, fse(os.path.expanduser('~')))
self.add('PLUGINS_BASE', None, os.path.join(basedir,
windowsify(u'plugins')))
windowsify('plugins')))
try:
self.add('TMP', None, fse(tempfile.gettempdir()))
except IOError, e:
......@@ -173,17 +173,17 @@ class ConfigPaths:
pass
def init_profile(self, profile=''):
conffile = windowsify(u'config')
pidfile = windowsify(u'gajim')
secretsfile = windowsify(u'secrets')
pluginsconfdir = windowsify(u'pluginsconfig')
conffile = windowsify('config')
pidfile = windowsify('gajim')
secretsfile = windowsify('secrets')
pluginsconfdir = windowsify('pluginsconfig')
if len(profile) > 0:
conffile += u'.' + profile
pidfile += u'.' + profile
secretsfile += u'.' + profile
pluginsconfdir += u'.' + profile
pidfile += u'.pid'
conffile += '.' + profile
pidfile += '.' + profile
secretsfile += '.' + profile
pluginsconfdir += '.' + profile
pidfile += '.pid'
self.add('CONFIG_FILE', TYPE_CONFIG, conffile)
self.add('PID_FILE', TYPE_CACHE, pidfile)
self.add('SECRETS_FILE', TYPE_DATA, secretsfile)
......
......@@ -1017,7 +1017,7 @@ class ConnectionHandlersBase:
gc_contact = gajim.contacts.get_gc_contact(self.name, obj.jid, nick)
if obj.receipt_request_tag and gajim.config.get_per('accounts',
self.name, 'answer_receipts') and ((contact and contact.sub \
not in (u'to', u'none')) or gc_contact) and obj.mtype != 'error':
not in ('to', 'none')) or gc_contact) and obj.mtype != 'error':
receipt = nbxmpp.Message(to=obj.fjid, typ='chat')
receipt.setID(obj.id_)
receipt.setTag('received', namespace='urn:xmpp:receipts',
......
......@@ -195,7 +195,7 @@ class DataField(ExtendedNode):
Human-readable description of field meaning
"""
def fget(self):
return self.getTagData('desc') or u''
return self.getTagData('desc') or ''
def fset(self, value):
assert isinstance(value, basestring)
......@@ -348,7 +348,7 @@ class StringField(DataField):
Value of field. May be any unicode string
"""
def fget(self):
return self.getTagData('value') or u''
return self.getTagData('value') or ''
def fset(self, value):
assert isinstance(value, basestring)
......@@ -494,7 +494,7 @@ class TextMultiField(DataField):
Value held in field
"""
def fget(self):
value = u''
value = ''
for element in self.iterTags('value'):
value += '\n' + element.getData()
return value[1:]
......@@ -643,7 +643,7 @@ class DataForm(ExtendedNode):
"""
# TODO: the same code is in TextMultiField. join them
def fget(self):
value = u''
value = ''
for valuenode in self.getTags('instructions'):
value += '\n' + valuenode.getData()
return value[1:]
......
......@@ -144,7 +144,7 @@ def parse_resource(resource):
if resource:
try:
from nbxmpp.stringprepare import resourceprep
return resourceprep.prepare(unicode(resource))
return resourceprep.prepare(resource)
except UnicodeError:
raise InvalidFormat, 'Invalid character in resource.'
......@@ -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))
user = nodeprep.prepare(unicode(user)).encode('utf-8')
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))
server = nameprep.prepare(unicode(server)).encode('utf-8')
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))
resource = resourceprep.prepare(unicode(resource)).encode('utf-8')
except UnicodeError:
raise InvalidFormat, _('Invalid character in resource.')
else:
......@@ -264,7 +264,7 @@ def get_uf_show(show, use_mnemonic = False):
uf_show = Q_('?contact has status:Unknown')
else:
uf_show = Q_('?contact has status:Has errors')
return unicode(uf_show)
return uf_show
def get_uf_sub(sub):
if sub == 'none':
......@@ -278,7 +278,7 @@ def get_uf_sub(sub):
else:
uf_sub = sub
return unicode(uf_sub)
return uf_sub
def get_uf_ask(ask):
if ask is None:
......@@ -288,7 +288,7 @@ def get_uf_ask(ask):
else:
uf_ask = ask
return unicode(uf_ask)
return uf_ask
def get_uf_role(role, plural = False):
''' plural determines if you get Moderators or Moderator'''
......@@ -577,9 +577,6 @@ def reduce_chars_newlines(text, max_chars = 0, max_lines = 0):
string = string[:max_chars - 3] + '...'
return string
if isinstance(text, str):
text = text.decode('utf-8')
if max_lines == 0:
lines = text.split('\n')
else:
......@@ -1431,7 +1428,7 @@ def get_proxy_info(account):
login = ['', '']
addr = env_http_proxy[0].split(':')
proxy = {'host': addr[0], 'type' : u'http', 'user':login[0]}
proxy = {'host': addr[0], 'type' : 'http', 'user':login[0]}
if len(addr) == 2:
proxy['port'] = addr[1]
......@@ -1442,7 +1439,7 @@ def get_proxy_info(account):
proxy['pass'] = login[1]
proxy['useauth'] = True
else:
proxy['pass'] = u''
proxy['pass'] = ''
return proxy
except Exception:
......
......@@ -37,11 +37,11 @@ def paragraph_direction_mark(text):
for char in text:
bidi = unicodedata.bidirectional(char)
if bidi == 'L':
return u'\u200E'
return '\u200E'
elif bidi == 'AL' or bidi == 'R':
return u'\u200F'
return '\u200F'
return u'\u200E'
return '\u200E'
APP = 'gajim'
DIR = defs.localedir
......@@ -61,7 +61,7 @@ if os.name == 'nt':
if lang:
os.environ['LANG'] = lang
gettext.install(APP, DIR, unicode = True)
gettext.install(APP, DIR, unicode=False)
if gettext._translations:
_translation = gettext._translations.values()[0]
else:
......
......@@ -53,7 +53,7 @@ def kwallet_get(folder, entry):
"-e", entry.encode('utf-8')], stdout=subprocess.PIPE)
pw = p.communicate()[0]
if p.returncode == 0:
return unicode(pw.decode('utf-8'))
return pw
if p.returncode == 1 or p.returncode == 4:
# ENOENT
return False
......
......@@ -188,7 +188,7 @@ class Logger:
def get_jids_already_in_db(self):
try:
self.cur.execute('SELECT jid FROM jids')
# list of tupples: [(u'aaa@bbb',), (u'cc@dd',)]
# list of tupples: [('aaa@bbb',), ('cc@dd',)]
rows = self.cur.fetchall()
except sqlite.DatabaseError:
raise exceptions.DatabaseMalformed
......@@ -1048,6 +1048,8 @@ class Logger:
FROM roster_entry re, jids j
WHERE re.account_jid_id=? AND j.jid_id=re.jid_id''', (account_jid_id,))
for jid, jid_id, name, subscription, ask in self.cur:
jid = jid.encode('utf-8')
name = name.encode('utf-8')
data[jid] = {}
if name:
data[jid]['name'] = name
......@@ -1071,6 +1073,7 @@ class Logger:
WHERE account_jid_id=? AND jid_id=?''',
(account_jid_id, data[jid]['id']))
for (group_name,) in self.cur:
group_name = group_name.encode('utf-8')
data[jid]['groups'].append(group_name)
del data[jid]['id']
......
......@@ -61,7 +61,7 @@ class OptionsParser:
for line in fd:
try:
line = line.decode('utf-8')
line = helpers.ensure_utf8_string(line)
except UnicodeDecodeError:
line = line.decode(locale.getpreferredencoding())
optname, key, subname, value = regex.match(line).groups()
......@@ -715,7 +715,7 @@ class OptionsParser:
"""
dirs = ['../data', gajim.gajimpaths.data_root, gajim.DATA_DIR]
if os.name != 'nt':
dirs.append(os.path.expanduser(u'~/.gajim'))
dirs.append(os.path.expanduser('~/.gajim'))
for evt in gajim.config.get_per('soundevents'):
path = gajim.config.get_per('soundevents', evt, 'path')
# absolute and relative passes are necessary
......
......@@ -120,7 +120,7 @@ else:
# in the JEP
# &nbsp; == u"\u00a0"
self.pub.writer.translator_class.attribution_formats['dash'] = (
u'\u2014', '')
'\u2014', '')
self.pub.process_programmatic_settings(settings_spec,
settings_overrides,
config_section)
......@@ -137,7 +137,7 @@ else:
output = self.pub.publish(enable_exit_status=enable_exit_status)
# kludge until we can get docutils to stop generating (rare) &nbsp;
# entities
return u'\u00a0'.join(self.pub.writer.parts['fragment'].strip().split(
return '\u00a0'.join(self.pub.writer.parts['fragment'].strip().split(
'&nbsp;'))
Generator = HTMLGenerator()
......
This diff is collapsed.
......@@ -114,12 +114,12 @@ 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,
returns u''. Useful for setting window title
returns ''. Useful for setting window title
"""
if self._data_form is not None:
if self._data_form.title is not None:
return self._data_form.title
return u''
return ''
title = property(get_title, None, None, 'Data form title')
......@@ -540,7 +540,7 @@ class SingleForm(Gtk.Table, object):
field)
widget.set_sensitive(readwrite)
if field.value is None:
field.value = u''
field.value = ''
widget.set_text(field.value)
else:
commonwidget=False
......
This diff is collapsed.
......@@ -800,7 +800,7 @@ _('This type of service does not contain any items to browse.'))
def on_address_comboboxentry_changed(self, widget):
if self.address_comboboxentry.get_active() != -1:
# user selected one of the entries so do auto-visit
jid = self.address_comboboxentry.get_child().get_text().decode('utf-8')
jid = self.address_comboboxentry.get_child().get_text()
try:
jid = helpers.parse_jid(jid)
except helpers.InvalidFormat, s:
......@@ -810,7 +810,7 @@ _('This type of service does not contain any items to browse.'))
self.travel(jid, '')
def on_go_button_clicked(self, widget):
jid = self.address_comboboxentry.get_child().get_text().decode('utf-8')
jid = self.address_comboboxentry.get_child().get_text()
try:
jid = helpers.parse_jid(jid)
except helpers.InvalidFormat, s:
......@@ -998,9 +998,9 @@ class AgentBrowser:
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
jid = model[iter_][0].decode('utf-8')
jid = model[iter_][0]
if jid:
node = model[iter_][1].decode('utf-8')
node = model[iter_][1]
self.window.open(jid, node)
def update_actions(self):
......@@ -1012,8 +1012,8 @@ class AgentBrowser:
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
jid = model[iter_][0].decode('utf-8')
node = model[iter_][1].decode('utf-8')
jid = model[iter_][0]
node = model[iter_][1]
if jid:
self.cache.get_info(jid, node, self._update_actions, nofetch = True)
......@@ -1035,8 +1035,8 @@ class AgentBrowser:
model, iter_ = self.window.services_treeview.get_selection().get_selected()
if not iter_:
return
jid = model[iter_][0].decode('utf-8')
node = model[iter_][1].decode('utf-8')