changeset d815b4a240ba in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=d815b4a240ba
description: xrange() -> list(range())
diffstat:
src/chat_control.py | 2 +-
src/command_system/implementation/execute.py | 2 +-
src/common/contacts.py | 4 +++-
src/common/socks5.py | 2 +-
src/config.py | 10 +++++-----
src/dataforms_widget.py | 5 ++---
src/gtkgui_helpers.py | 4 ++--
src/message_window.py | 6 +++---
src/plugins/gui.py | 2 +-
src/roster_window.py | 2 +-
10 files changed, 20 insertions(+), 19 deletions(-)
diffs (202 lines):
diff -r 5f81631ea012 -r d815b4a240ba src/chat_control.py
--- a/src/chat_control.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/chat_control.py Wed Jan 02 18:17:51 2013 +0100
@@ -916,7 +916,7 @@
scroll = False if pos == size else True # are we scrolling?
# we don't want size of the buffer to grow indefinately
max_size = gajim.config.get('key_up_lines')
- for i in xrange(size - max_size + 1):
+ for i in range(size - max_size + 1):
if pos == 0:
break
history.pop(0)
diff -r 5f81631ea012 -r d815b4a240ba src/command_system/implementation/execute.py
--- a/src/command_system/implementation/execute.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/command_system/implementation/execute.py Wed Jan 02 18:17:51 2013 +0100
@@ -68,7 +68,7 @@
@classmethod
def poller(cls, processor, popen):
- for x in xrange(cls.POLL_COUNT):
+ for x in list(range(cls.POLL_COUNT)):
yield cls.brush(processor, popen)
cls.overdue(processor, popen)
yield False
diff -r 5f81631ea012 -r d815b4a240ba src/common/contacts.py
--- a/src/common/contacts.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/common/contacts.py Wed Jan 02 18:17:51 2013 +0100
@@ -28,6 +28,8 @@
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
##
+from functools import cmp_to_key
+
try:
from common import caps_cache
from common.account import Account
@@ -848,7 +850,7 @@
Which of the family will be the big brother under wich all others will be
?
"""
- family.sort(cmp=self._compare_metacontacts)
+ family.sort(key=cmp_to_key(self._compare_metacontacts))
return family[-1]
diff -r 5f81631ea012 -r d815b4a240ba src/common/socks5.py
--- a/src/common/socks5.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/common/socks5.py Wed Jan 02 18:17:51 2013 +0100
@@ -781,7 +781,7 @@
auth_mechanisms = []
try:
num_auth = struct.unpack('!xB', buff[:2])[0]
- for i in xrange(num_auth):
+ for i in list(range(num_auth)):
mechanism, = struct.unpack('!B', buff[1 + i])
auth_mechanisms.append(mechanism)
except Exception:
diff -r 5f81631ea012 -r d815b4a240ba src/config.py
--- a/src/config.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/config.py Wed Jan 02 18:17:51 2013 +0100
@@ -173,7 +173,7 @@
if dir_ != '.svn':
l.append(dir_)
l.append(_('Disabled'))
- for i in xrange(len(l)):
+ for i in range(len(l)):
model.append([l[i]])
if gajim.config.get('emoticons_theme') == l[i]:
emoticons_combobox.set_active(i)
@@ -243,7 +243,7 @@
l.append(dir)
if l.count == 0:
l.append(' ')
- for i in xrange(len(l)):
+ for i in range(len(l)):
preview = Gtk.Image()
files = []
files.append(os.path.join(helpers.get_iconset_path(l[i]), '16x16',
@@ -1279,7 +1279,7 @@
model.clear()
l = gajim.config.get_per('proxies')
l.insert(0, _('None'))
- for i in xrange(len(l)):
+ for i in range(len(l)):
model.append([l[i]])
if our_proxy == l[i]:
proxy_combobox.set_active(i)
@@ -1766,7 +1766,7 @@
proxy_combobox.set_model(model)
l = gajim.config.get_per('proxies')
l.insert(0, _('None'))
- for i in xrange(len(l)):
+ for i in range(len(l)):
model.append([l[i]])
if our_proxy == l[i]:
proxy_combobox.set_active(i)
@@ -3757,7 +3757,7 @@
proxies_combobox.set_model(model)
l = gajim.config.get_per('proxies')
l.insert(0, _('None'))
- for i in xrange(len(l)):
+ for i in range(len(l)):
model.append([l[i]])
proxies_combobox.set_active(0)
diff -r 5f81631ea012 -r d815b4a240ba src/dataforms_widget.py
--- a/src/dataforms_widget.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/dataforms_widget.py Wed Jan 02 18:17:51 2013 +0100
@@ -277,7 +277,7 @@
selection = self.records_treeview.get_selection()
model, rowrefs = selection.get_selected_rows()
# rowref is a list of paths
- for i in xrange(len(rowrefs)):
+ for i in list(range(len(rowrefs))):
rowrefs[i] = Gtk.TreeRowReference(model, rowrefs[i])
# rowref is a list of row references; need to convert because we will
# modify the model, paths would change
@@ -566,8 +566,7 @@
for uri in field.media.uris:
if uri.type_.startswith('image/'):
try:
- img_data = base64.b64decode(uri.uri_data.encode(
- 'utf-8')).decode('utf-8')
+ img_data = base64.decodestring(uri.uri_data)
pixbuf_l = GdkPixbuf.PixbufLoader()
pixbuf_l.write(img_data)
pixbuf_l.close()
diff -r 5f81631ea012 -r d815b4a240ba src/gtkgui_helpers.py
--- a/src/gtkgui_helpers.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/gtkgui_helpers.py Wed Jan 02 18:17:51 2013 +0100
@@ -317,7 +317,7 @@
def __str__(self):
prettydigest = ''
- for i in xrange(0, len(self.digest), 2):
+ for i in list(range(0, len(self.digest), 2)):
prettydigest += self.digest[i:i + 2] + ':'
return prettydigest[:-1]
@@ -1102,7 +1102,7 @@
"""
if isinstance (widget, Gtk.Container):
children = widget.get_children()
- for i in xrange (len (children)):
+ for i in list(range (len (children))):
label_set_autowrap(children[i])
elif isinstance(widget, Gtk.Label):
widget.set_line_wrap(True)
diff -r 5f81631ea012 -r d815b4a240ba src/message_window.py
--- a/src/message_window.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/message_window.py Wed Jan 02 18:17:51 2013 +0100
@@ -106,7 +106,7 @@
'<Control>b', '<Control>F4',
'<Control>w', '<Control>Page_Up', '<Control>Page_Down', '<Alt>Right',
'<Alt>Left', '<Alt>d', '<Alt>c', '<Alt>m', '<Alt>t', 'Escape'] + \
- ['<Alt>'+str(i) for i in xrange(10)]
+ ['<Alt>'+str(i) for i in list(range(10))]
accel_group = Gtk.AccelGroup()
for key in keys:
keyval, mod = Gtk.accelerator_parse(key)
@@ -856,7 +856,7 @@
to_right = False
horiz = self.notebook.get_tab_pos() == Gtk.PositionType.TOP or \
self.notebook.get_tab_pos() == Gtk.PositionType.BOTTOM
- for i in xrange(self.notebook.get_n_pages()):
+ for i in list(range(self.notebook.get_n_pages())):
page = self.notebook.get_nth_page(i)
tab = self.notebook.get_tab_label(page)
tab_alloc = tab.get_allocation()
@@ -882,7 +882,7 @@
Find the page num of the tab label
"""
page_num = -1
- for i in xrange(self.notebook.get_n_pages()):
+ for i in list(range(self.notebook.get_n_pages())):
page = self.notebook.get_nth_page(i)
tab = self.notebook.get_tab_label(page)
if tab == tab_label:
diff -r 5f81631ea012 -r d815b4a240ba src/plugins/gui.py
--- a/src/plugins/gui.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/plugins/gui.py Wed Jan 02 18:17:51 2013 +0100
@@ -264,7 +264,7 @@
return
model = self.installed_plugins_model
- for row in xrange(len(model)):
+ for row in list(range(len(model))):
if plugin == model[row][PLUGIN]:
model.remove(model.get_iter((row, PLUGIN)))
break
diff -r 5f81631ea012 -r d815b4a240ba src/roster_window.py
--- a/src/roster_window.py Wed Jan 02 17:53:42 2013 +0100
+++ b/src/roster_window.py Wed Jan 02 18:17:51 2013 +0100
@@ -3225,7 +3225,7 @@
'attached_gpg_keys').split()
keys = {}
keyID = _('None')
- for i in xrange(len(attached_keys)/2):
+ for i in list(range(len(attached_keys)/2)):
keys[attached_keys[2*i]] = attached_keys[2*i+1]
if attached_keys[2*i] == contact.jid:
keyID = attached_keys[2*i+1]
changeset 0086c1032eaa in /home/hg/repos/gajim
details:http://hg.gajim.org/gajim?cmd=changeset;node=0086c1032eaa
description: print -> print()
diffstat:
src/adhoc_commands.py | 2 +-
src/common/check_paths.py | 54 ++++++++++----------
src/common/configpaths.py | 4 +-
src/common/connection_handlers.py | 4 +-
src/common/connection_handlers_events.py | 8 +-
src/common/dbus_support.py | 16 +++---
src/common/idle.py | 4 +-
src/common/jingle_transport.py | 2 +-
src/common/logger.py | 4 +-
src/common/logging_helpers.py | 4 +-
src/common/multimedia_helpers.py | 2 +-
src/common/optparser.py | 5 +-
src/common/resolver.py | 2 +-
src/common/rst_xhtml_generator.py | 12 ++--
src/common/zeroconf/roster_zeroconf.py | 12 ----
src/dataforms_widget.py | 2 +-
src/dialogs.py | 1 -
src/gajim-remote.py | 27 +++++----
src/gajim.py | 28 +++++-----
src/gtkgui_helpers.py | 14 ++--
src/gui_interface.py | 4 +-
src/ipython_view.py | 4 +-
src/music_track_listener.py | 8 +-
test/integration/test_resolver.py | 2 +-
test/integration/test_xmpp_client_nb.py | 2 +-
test/runtests.py | 8 +-
test/unit/test_socks5.py | 84 ++++++++++++++++----------------
27 files changed, 154 insertions(+), 165 deletions(-)
diffs (truncated from 1009 to 300 lines):
diff -r 093f965f539c -r 0086c1032eaa src/adhoc_commands.py
--- a/src/adhoc_commands.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/adhoc_commands.py Tue Jan 01 19:36:56 2013 +0100
@@ -159,7 +159,7 @@
return self.stage_adhoc_commands_window_delete_event(self.window)
def __del__(self):
- print 'Object has been deleted.'
+ print('Object has been deleted.')
# stage 1: waiting for command list
def stage1(self):
diff -r 093f965f539c -r 0086c1032eaa src/common/check_paths.py
--- a/src/common/check_paths.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/check_paths.py Tue Jan 01 19:36:56 2013 +0100
@@ -36,7 +36,7 @@
import sqlite3 as sqlite
def create_log_db():
- print _('creating logs database')
+ print(_('creating logs database'))
con = sqlite.connect(logger.LOG_DB_PATH)
os.chmod(logger.LOG_DB_PATH, 0600) # rw only for us
cur = con.cursor()
@@ -84,7 +84,7 @@
con.close()
def create_cache_db():
- print _('creating cache database')
+ print(_('creating cache database'))
con = sqlite.connect(logger.CACHE_DB_PATH)
os.chmod(logger.CACHE_DB_PATH, 0600) # rw only for us
cur = con.cursor()
@@ -128,7 +128,7 @@
con.close()
def split_db():
- print 'spliting database'
+ print('spliting database')
if os.name == 'nt':
try:
import configpaths
@@ -162,8 +162,8 @@
cur.executescript('DROP TABLE %s;' % table)
con.commit()
except sqlite.OperationalError, e:
- print >> sys.stderr, 'error moving table %s to cache.db: %s' % \
- (table, str(e))
+ print('error moving table %s to cache.db: %s' % (table, str(e)),
+ file=sys.stderr)
con.close()
logger.CACHE_DB_PATH = tmp
@@ -249,7 +249,7 @@
continue
if not os.path.exists(src):
continue
- print 'moving %s to %s' % (src, dst)
+ print(_('moving %s to %s') % (src, dst))
shutil.move(src, dst)
gajim.logger.init_vars()
gajim.logger.attach_cache_database()
@@ -275,57 +275,57 @@
if not os.path.exists(MY_DATA):
create_path(MY_DATA)
elif os.path.isfile(MY_DATA):
- print _('%s is a file but it should be a directory') % MY_DATA
- print _('Gajim will now exit')
+ print(_('%s is a file but it should be a directory') % MY_DATA)
+ print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(MY_CONFIG):
create_path(MY_CONFIG)
elif os.path.isfile(MY_CONFIG):
- print _('%s is a file but it should be a directory') % MY_CONFIG
- print _('Gajim will now exit')
+ print(_('%s is a file but it should be a directory') % MY_CONFIG)
+ print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(MY_CACHE):
create_path(MY_CACHE)
elif os.path.isfile(MY_CACHE):
- print _('%s is a file but it should be a directory') % MY_CACHE
- print _('Gajim will now exit')
+ print(_('%s is a file but it should be a directory') % MY_CACHE)
+ print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(VCARD_PATH):
create_path(VCARD_PATH)
elif os.path.isfile(VCARD_PATH):
- print _('%s is a file but it should be a directory') % VCARD_PATH
- print _('Gajim will now exit')
+ print(_('%s is a file but it should be a directory') % VCARD_PATH)
+ print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(AVATAR_PATH):
create_path(AVATAR_PATH)
elif os.path.isfile(AVATAR_PATH):
- print _('%s is a file but it should be a directory') % AVATAR_PATH
- print _('Gajim will now exit')
+ print(_('%s is a file but it should be a directory') % AVATAR_PATH)
+ print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(LOG_DB_FOLDER):
create_path(LOG_DB_FOLDER)
elif os.path.isfile(LOG_DB_FOLDER):
- print _('%s is a file but it should be a directory') % LOG_DB_FOLDER
- print _('Gajim will now exit')
+ print(_('%s is a file but it should be a directory') % LOG_DB_FOLDER)
+ print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(PLUGINS_CONFIG_PATH):
create_path(PLUGINS_CONFIG_PATH)
elif os.path.isfile(PLUGINS_CONFIG_PATH):
- print _('%s is a file but it should be a directory') % PLUGINS_CONFIG_PATH
- print _('Gajim will now exit')
+ print(_('%s is a file but it should be a directory') % PLUGINS_CONFIG_PATH)
+ print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(CACHE_DB_FOLDER):
create_path(CACHE_DB_FOLDER)
elif os.path.isfile(CACHE_DB_FOLDER):
- print _('%s is a file but it should be a directory') % CACHE_DB_FOLDER
- print _('Gajim will now exit')
+ print(_('%s is a file but it should be a directory') % CACHE_DB_FOLDER)
+ print(_('Gajim will now exit'))
sys.exit()
check_and_possibly_move_config()
@@ -334,16 +334,16 @@
create_log_db()
gajim.logger.init_vars()
elif os.path.isdir(LOG_DB_PATH):
- print _('%s is a directory but should be a file') % LOG_DB_PATH
- print _('Gajim will now exit')
+ print(_('%s is a directory but should be a file') % LOG_DB_PATH)
+ print(_('Gajim will now exit'))
sys.exit()
if not os.path.exists(CACHE_DB_PATH):
create_cache_db()
gajim.logger.attach_cache_database()
elif os.path.isdir(CACHE_DB_PATH):
- print _('%s is a directory but should be a file') % CACHE_DB_PATH
- print _('Gajim will now exit')
+ 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):
@@ -363,5 +363,5 @@
create_path(head)
if os.path.exists(directory):
return
- print _('creating %s directory') % directory
+ print(('creating %s directory') % directory)
os.mkdir(directory, 0700)
diff -r 093f965f539c -r 0086c1032eaa src/common/configpaths.py
--- a/src/common/configpaths.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/configpaths.py Tue Jan 01 19:36:56 2013 +0100
@@ -162,8 +162,8 @@
try:
self.add('TMP', None, fse(tempfile.gettempdir()))
except IOError, e:
- print >> sys.stderr, 'Error opening tmp folder: %s\nUsing %s' % (
- str(e), os.path.expanduser('~'))
+ print('Error opening tmp folder: %s\nUsing %s' % (str(e),
+ os.path.expanduser('~')), file=sys.stderr)
self.add('TMP', None, fse(os.path.expanduser('~')))
try:
diff -r 093f965f539c -r 0086c1032eaa src/common/connection_handlers.py
--- a/src/common/connection_handlers.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/connection_handlers.py Tue Jan 01 19:36:56 2013 +0100
@@ -593,7 +593,7 @@
elif self.awaiting_answers[id_][0] == ARCHIVING_COLLECTIONS_ARRIVED:
# TODO
- print 'ARCHIVING_COLLECTIONS_ARRIVED'
+ print('ARCHIVING_COLLECTIONS_ARRIVED')
elif self.awaiting_answers[id_][0] == ARCHIVING_COLLECTION_ARRIVED:
def save_if_not_exists(with_, nick, direction, tim, payload):
@@ -603,7 +603,7 @@
gajim.logger.save_if_not_exists(with_, direction, tim,
msg=payload[0].getData(), nick=nick)
elif payload[0].getName() == 'message':
- print 'Not implemented'
+ print('Not implemented')
chat = iq_obj.getTag('chat')
if chat:
with_ = chat.getAttr('with')
diff -r 093f965f539c -r 0086c1032eaa src/common/connection_handlers_events.py
--- a/src/common/connection_handlers_events.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/connection_handlers_events.py Tue Jan 01 19:36:56 2013 +0100
@@ -366,10 +366,10 @@
try:
j = helpers.parse_jid(jid)
except Exception:
- print >> sys.stderr, _('JID %s is not RFC compliant. It '
- 'will not be added to your roster. Use roster '
- 'management tools such as '
- 'http://jru.jabberstudio.org/ to remove it') % jid
+ print(_('JID %s is not RFC compliant. It will not be added '
+ 'to your roster. Use roster management tools such as '
+ 'http://jru.jabberstudio.org/ to remove it') % jid,
+ file=sys.stderr)
else:
infos = raw_roster[jid]
if jid != our_jid and (not infos['subscription'] or \
diff -r 093f965f539c -r 0086c1032eaa src/common/dbus_support.py
--- a/src/common/dbus_support.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/dbus_support.py Tue Jan 01 19:36:56 2013 +0100
@@ -38,8 +38,8 @@
except ImportError:
supported = False
if not os.name == 'nt': # only say that to non Windows users
- print _('D-Bus python bindings are missing in this computer')
- print _('D-Bus capabilities of Gajim cannot be used')
+ print(_('D-Bus python bindings are missing in this computer'))
+ print(_('D-Bus capabilities of Gajim cannot be used'))
else:
try:
# test if dbus-x11 is installed
@@ -49,14 +49,14 @@
except dbus.DBusException:
supported = False
if not os.name == 'nt': # only say that to non Windows users
- print _('D-Bus does not run correctly on this machine')
- print _('D-Bus capabilities of Gajim cannot be used')
+ print(_('D-Bus does not run correctly on this machine'))
+ print(_('D-Bus capabilities of Gajim cannot be used'))
except exceptions.SystemBusNotPresent:
- print _('D-Bus does not run correctly on this machine: system bus not '
- 'present')
+ print(_('D-Bus does not run correctly on this machine: system bus not '
+ 'present'))
except exceptions.SessionBusNotPresent:
- print _('D-Bus does not run correctly on this machine: session bus not '
- 'present')
+ print(_('D-Bus does not run correctly on this machine: session bus not '
+ 'present'))
class SystemBus:
"""
diff -r 093f965f539c -r 0086c1032eaa src/common/idle.py
--- a/src/common/idle.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/idle.py Tue Jan 01 19:36:56 2013 +0100
@@ -94,6 +94,6 @@
if __name__ == '__main__':
import time
time.sleep(2.1)
- print getIdleSec()
+ print(getIdleSec())
close()
- print getIdleSec()
+ print(getIdleSec())
diff -r 093f965f539c -r 0086c1032eaa src/common/jingle_transport.py
--- a/src/common/jingle_transport.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/jingle_transport.py Tue Jan 01 19:36:56 2013 +0100
@@ -401,7 +401,7 @@
if 'type' in candidate and candidate['type'] in types:
cand.type = types[candidate['type']]
else:
- print 'Unknown type %s', candidate['type']
+ print('Unknown type %s' % candidate['type'])
candidates.append(cand)
self.remote_candidates.extend(candidates)
return candidates
diff -r 093f965f539c -r 0086c1032eaa src/common/logger.py
--- a/src/common/logger.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/logger.py Tue Jan 01 19:36:56 2013 +0100
@@ -169,7 +169,7 @@
try:
self.con.commit()
except sqlite.OperationalError, e:
- print >> sys.stderr, str(e)
+ print(str(e), file=sys.stderr)
self.commit_timout_id = None
return False
@@ -415,7 +415,7 @@
self.con.commit()
message_id = self.cur.lastrowid
except sqlite.OperationalError, e:
- print >> sys.stderr, str(e)
+ print(str(e), file=sys.stderr)
else:
self._timeout_commit()
if message_id:
diff -r 093f965f539c -r 0086c1032eaa src/common/logging_helpers.py
--- a/src/common/logging_helpers.py Wed Jan 02 00:31:13 2013 +0400
+++ b/src/common/logging_helpers.py Tue Jan 01 19:36:56 2013 +0100