changeset 690dea6f873b in /home/hg/repos/gajim

details:http://hg.gajim.org/gajim?cmd=changeset;node=690dea6f873b
description: fix imports and many py3 changements

diffstat:

 plugins/dbus_plugin/plugin.py                   |   2 +-
 src/advanced_configuration_window.py            |   1 -
 src/chat_control.py                             |   4 +-
 src/command_system/dispatcher.py                |   5 +-
 src/command_system/framework.py                 |   4 +-
 src/command_system/implementation/execute.py    |   4 +-
 src/command_system/implementation/middleware.py |   3 +-
 src/command_system/mapping.py                   |  23 ++++-----
 src/common/caps_cache.py                        |   9 ++-
 src/common/check_paths.py                       |  10 ++--
 src/common/commands.py                          |   2 +-
 src/common/config.py                            |  14 +----
 src/common/configpaths.py                       |   4 +-
 src/common/connection.py                        |   2 +-
 src/common/connection_handlers.py               |   4 +-
 src/common/connection_handlers_events.py        |  30 ++++++++++--
 src/common/contacts.py                          |   4 +-
 src/common/gajim.py                             |  16 ++----
 src/common/gpg.py                               |   2 +-
 src/common/helpers.py                           |  37 ++++++++-------
 src/common/i18n.py                              |   2 +-
 src/common/jingle.py                            |  12 ++--
 src/common/jingle_content.py                    |   4 +-
 src/common/jingle_ft.py                         |   8 +-
 src/common/jingle_ftstates.py                   |   4 +-
 src/common/jingle_rtp.py                        |  11 ++--
 src/common/jingle_session.py                    |  11 ++--
 src/common/jingle_transport.py                  |   2 +-
 src/common/jingle_xtls.py                       |   5 +-
 src/common/logger.py                            |  18 +++---
 src/common/nec.py                               |   2 +-
 src/common/optparser.py                         |   8 +--
 src/common/pep.py                               |  40 ----------------
 src/common/protocol/bytestream.py               |   2 +-
 src/common/proxy65_manager.py                   |   2 +-
 src/common/pubsub.py                            |  14 +++--
 src/common/sleepy.py                            |   3 +-
 src/common/socks5.py                            |   6 +-
 src/common/stanza_session.py                    |   2 +-
 src/common/zeroconf/connection_zeroconf.py      |   2 +-
 src/common/zeroconf/zeroconf_avahi.py           |   2 +-
 src/config.py                                   |   4 +-
 src/conversation_textview.py                    |   8 +-
 src/dialogs.py                                  |  15 ++---
 src/disco.py                                    |   4 +-
 src/gajim.py                                    |   4 +
 src/gtkexcepthook.py                            |   6 +-
 src/gtkgui_helpers.py                           |  59 ++++++++++++++----------
 src/gui_interface.py                            |  20 ++++----
 src/htmltextview.py                             |   9 ++-
 src/notify.py                                   |   3 +
 src/plugins/__init__.py                         |   4 +-
 src/plugins/helpers.py                          |   2 +-
 src/plugins/plugin.py                           |   8 +-
 src/plugins/pluginmanager.py                    |  24 +++++-----
 src/remote_control.py                           |   2 +-
 src/roster_window.py                            |  18 +++---
 src/tooltips.py                                 |   4 +-
 test/lib/mock.py                                |   2 +-
 test/unit/test_jingle.py                        |   4 +-
 60 files changed, 261 insertions(+), 279 deletions(-)

diffs (truncated from 1880 to 300 lines):

diff -r e479aa48ab71 -r 690dea6f873b plugins/dbus_plugin/plugin.py
--- a/plugins/dbus_plugin/plugin.py     Tue Jan 01 23:18:36 2013 +0100
+++ b/plugins/dbus_plugin/plugin.py     Wed Jan 02 13:54:02 2013 +0100
@@ -407,7 +407,7 @@
                     return DBUS_DICT_SV()
                 jid = self._get_real_jid(jid)
 
-                cached_vcard = 
gajim.connections.values()[0].get_cached_vcard(jid)
+                cached_vcard = 
list(gajim.connections.values())[0].get_cached_vcard(jid)
                 if cached_vcard:
                     return get_dbus_struct(cached_vcard)
 
diff -r e479aa48ab71 -r 690dea6f873b src/advanced_configuration_window.py
--- a/src/advanced_configuration_window.py      Tue Jan 01 23:18:36 2013 +0100
+++ b/src/advanced_configuration_window.py      Wed Jan 02 13:54:02 2013 +0100
@@ -311,7 +311,6 @@
                             value = str(option)
                         except:
                             value = option
-                    value = helpers.ensure_utf8_string(value)
                 self.model.append(parent, [name, value, type_])
 
     def visible_func(self, model, treeiter, data):
diff -r e479aa48ab71 -r 690dea6f873b src/chat_control.py
--- a/src/chat_control.py       Tue Jan 01 23:18:36 2013 +0100
+++ b/src/chat_control.py       Wed Jan 02 13:54:02 2013 +0100
@@ -1785,7 +1785,7 @@
         pep = self.contact.pep
         img = self._pep_images[pep_type]
         if pep_type in pep:
-            img.set_from_pixbuf(pep[pep_type].asPixbufIcon())
+            
img.set_from_pixbuf(gtkgui_helpers.get_pep_as_pixbuf(pep[pep_type]))
             img.set_tooltip_markup(pep[pep_type].asMarkupText())
             img.show()
         else:
@@ -3020,7 +3020,7 @@
         # It's why I set it transparent.
         image = self.xml.get_object('avatar_image')
         pixbuf = image.get_pixbuf()
-        pixbuf.fill(0xffffff00L) # RGBA
+        pixbuf.fill(0xffffff00) # RGBA
         image.queue_draw()
 
         screen_w = Gdk.Screen.width()
diff -r e479aa48ab71 -r 690dea6f873b src/command_system/dispatcher.py
--- a/src/command_system/dispatcher.py  Tue Jan 01 23:18:36 2013 +0100
+++ b/src/command_system/dispatcher.py  Wed Jan 02 13:54:02 2013 +0100
@@ -31,7 +31,6 @@
 over the process.
 """
 
-from types import NoneType
 from .tools import remove
 
 COMMANDS = {}
@@ -71,7 +70,7 @@
     return isinstance(attribute, Command)
 
 def is_root(namespace):
-    metaclass = namespace.get("__metaclass__", NoneType)
+    metaclass = namespace.get("__metaclass__", None)
     return issubclass(metaclass, Dispatchable)
 
 def get_command(host, name):
@@ -83,7 +82,7 @@
 def list_commands(host):
     for container in CONTAINERS[host]:
         commands = COMMANDS[container]
-        for name, command in commands.iteritems():
+        for name, command in commands.items():
             yield name, command
 
 class Dispatchable(type):
diff -r e479aa48ab71 -r 690dea6f873b src/command_system/framework.py
--- a/src/command_system/framework.py   Tue Jan 01 23:18:36 2013 +0100
+++ b/src/command_system/framework.py   Wed Jan 02 13:54:02 2013 +0100
@@ -25,7 +25,7 @@
 
 from .dispatcher import Host, Container
 from .dispatcher import get_command, list_commands
-from mmapping import parse_arguments, adapt_arguments
+from .mapping import parse_arguments, adapt_arguments
 from .errors import DefinitionError, CommandError, NoCommandError
 
 class CommandHost(object):
@@ -153,7 +153,7 @@
 
         # Automatically set all the properties passed to a constructor
         # by the command decorator.
-        for key, value in properties.iteritems():
+        for key, value in properties.items():
             setattr(self, key, value)
 
     def __call__(self, *args, **kwargs):
diff -r e479aa48ab71 -r 690dea6f873b 
src/command_system/implementation/execute.py
--- a/src/command_system/implementation/execute.py      Tue Jan 01 23:18:36 
2013 +0100
+++ b/src/command_system/implementation/execute.py      Wed Jan 02 13:54:02 
2013 +0100
@@ -35,7 +35,7 @@
 from subprocess import Popen, PIPE
 from os.path import expanduser
 
-from glib import timeout_add
+from gi.repository import GObject
 
 from ..framework import CommandContainer, command, doc
 from .hosts import *
@@ -64,7 +64,7 @@
     @classmethod
     def monitor(cls, processor, popen):
         poller = cls.poller(processor, popen)
-        timeout_add(cls.POLL_INTERVAL, poller.next)
+        GObject.timeout_add(cls.POLL_INTERVAL, poller.next)
 
     @classmethod
     def poller(cls, processor, popen):
diff -r e479aa48ab71 -r 690dea6f873b 
src/command_system/implementation/middleware.py
--- a/src/command_system/implementation/middleware.py   Tue Jan 01 23:18:36 
2013 +0100
+++ b/src/command_system/implementation/middleware.py   Wed Jan 02 13:54:02 
2013 +0100
@@ -31,7 +31,6 @@
 don't need to dig up the code itself to write basic commands.
 """
 
-from types import StringTypes
 from traceback import print_exc
 
 from gi.repository import Pango
@@ -98,7 +97,7 @@
     def command_postprocessor(self, command, name, arguments, args, kwargs, 
value):
         # If command returns a string - print it to a user. A convenient
         # and sufficient in most simple cases shortcut to a using echo.
-        if value and isinstance(value, StringTypes):
+        if value and isinstance(value, str):
             self.echo(value)
 
 class CommandTools:
diff -r e479aa48ab71 -r 690dea6f873b src/command_system/mapping.py
--- a/src/command_system/mapping.py     Tue Jan 01 23:18:36 2013 +0100
+++ b/src/command_system/mapping.py     Wed Jan 02 13:54:02 2013 +0100
@@ -23,7 +23,6 @@
 """
 
 import re
-from types import BooleanType, UnicodeType
 from operator import itemgetter
 
 from .errors import DefinitionError, CommandError
@@ -62,7 +61,7 @@
     """
     args, opts = [], []
 
-    def intersects_opts((given_start, given_end)):
+    def intersects_opts(given_start, given_end):
         """
         Check if given span intersects with any of options.
         """
@@ -71,7 +70,7 @@
                 return True
         return False
 
-    def intersects_args((given_start, given_end)):
+    def intersects_args(given_start, given_end):
         """
         Check if given span intersects with any of arguments.
         """
@@ -97,14 +96,14 @@
     # conflicted sectors. Remove any arguments that intersect with
     # options.
     for arg, position in args[:]:
-        if intersects_opts(position):
+        if intersects_opts(*position):
             args.remove((arg, position))
 
     # Primitive but sufficiently effective way of disposing of
     # conflicted sectors. Remove any options that intersect with
     # arguments.
     for key, value, position in opts[:]:
-        if intersects_args(position):
+        if intersects_args(*position):
             opts.remove((key, value, position))
 
     return args, opts
@@ -207,7 +206,7 @@
     # corresponding optin has been given.
     if command.expand:
         expanded = []
-        for spec_key, spec_value in norm_kwargs.iteritems():
+        for spec_key, spec_value in norm_kwargs.items():
             letter = spec_key[0] if len(spec_key) > 1 else None
             if letter and letter not in expanded:
                 for index, (key, value, position) in enumerate(opts):
@@ -219,7 +218,7 @@
     # Detect switches and set their values accordingly. If any of them
     # carries a value - append it to args.
     for index, (key, value, position) in enumerate(opts):
-        if isinstance(norm_kwargs.get(key), BooleanType):
+        if isinstance(norm_kwargs.get(key), bool):
             opts[index] = (key, True, position)
             if value:
                 args.append((value, position))
@@ -231,8 +230,8 @@
 
     # Stripping down position information supplied with arguments and
     # options as it won't be needed again.
-    args = map(lambda (arg, position): arg, args)
-    opts = map(lambda (key, value, position): (key, value), opts)
+    args = map(lambda t: t[0], t[1])
+    opts = map(lambda t: (t[0], t[1]), opts)
 
     # If command has extra option enabled - collect all extra arguments
     # and pass them to a last positional argument command defines as a
@@ -265,8 +264,8 @@
     # Normally this does not happen unless overlapping is enabled.
     for key, value in opts:
         initial = norm_kwargs.get(key)
-        if isinstance(initial, BooleanType):
-            if not isinstance(value, BooleanType):
+        if isinstance(initial, bool):
+            if not isinstance(value, bool):
                 raise CommandError("%s: Switch can not take an argument" % 
key, command)
 
     # Inject the source arguments as a string as a first argument, if
@@ -299,7 +298,7 @@
         letter = key[0]
         key = key.replace('_', '-')
 
-        if isinstance(value, BooleanType):
+        if isinstance(value, bool):
             value = str()
         else:
             value = '=%s' % value
diff -r e479aa48ab71 -r 690dea6f873b src/common/caps_cache.py
--- a/src/common/caps_cache.py  Tue Jan 01 23:18:36 2013 +0100
+++ b/src/common/caps_cache.py  Wed Jan 02 13:54:02 2013 +0100
@@ -130,7 +130,8 @@
         return 1
 
     S = ''
-    identities.sort(cmp=sort_identities_func)
+    from functools import cmp_to_key
+    identities.sort(key=cmp_to_key(sort_identities_func))
     for i in identities:
         c = i['category']
         type_ = i.get('type', '')
@@ -140,7 +141,7 @@
     features.sort()
     for f in features:
         S += '%s<' % f
-    dataforms.sort(cmp=sort_dataforms_func)
+    dataforms.sort(key=cmp_to_key(sort_dataforms_func))
     for dataform in dataforms:
         # fields indexed by var
         fields = {}
@@ -157,9 +158,9 @@
                 S += '%s<' % value
 
     if hash_method == 'sha-1':
-        hash_ = hashlib.sha1(S)
+        hash_ = hashlib.sha1(S.encode('utf-8'))
     elif hash_method == 'md5':
-        hash_ = hashlib.md5(S)
+        hash_ = hashlib.md5(S.encode('utf-8'))
     else:
         return ''
     return base64.b64encode(hash_.digest())
diff -r e479aa48ab71 -r 690dea6f873b src/common/check_paths.py
--- a/src/common/check_paths.py Tue Jan 01 23:18:36 2013 +0100
+++ b/src/common/check_paths.py Wed Jan 02 13:54:02 2013 +0100
@@ -38,7 +38,7 @@
 def create_log_db():
     print(_('creating logs database'))
     con = sqlite.connect(logger.LOG_DB_PATH)
-    os.chmod(logger.LOG_DB_PATH, 0600) # rw only for us
+    os.chmod(logger.LOG_DB_PATH, 0o600) # rw only for us
     cur = con.cursor()
     # create the tables
     # kind can be
@@ -86,7 +86,7 @@
 def create_cache_db():
     print(_('creating cache database'))
     con = sqlite.connect(logger.CACHE_DB_PATH)
-    os.chmod(logger.CACHE_DB_PATH, 0600) # rw only for us
+    os.chmod(logger.CACHE_DB_PATH, 0o600) # rw only for us
     cur = con.cursor()
     cur.executescript(
             '''
@@ -177,7 +177,7 @@
     vars['MY_ICONSETS_PATH'] = gajim.MY_ICONSETS_PATH
     vars['MY_MOOD_ICONSETS_PATH'] = gajim.MY_MOOD_ICONSETS_PATH
     vars['MY_ACTIVITY_ICONSETS_PATH'] = gajim.MY_ACTIVITY_ICONSETS_PATH
-    import configpaths
+    from common import configpaths
     MY_DATA = configpaths.gajimpaths['MY_DATA']
     MY_CONFIG = configpaths.gajimpaths['MY_CONFIG']
     MY_CACHE = configpaths.gajimpaths['MY_CACHE']
@@ -263,7 +263,7 @@
 
     VCARD_PATH = gajim.VCARD_PATH
     AVATAR_PATH = gajim.AVATAR_PATH
-    import configpaths
+    from common import configpaths
_______________________________________________
Commits mailing list
[email protected]
http://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to