Add dependecy on six

This commit is contained in:
Calum Lind 2017-03-16 23:40:32 +00:00
parent 4247013446
commit 200e8f552b
7 changed files with 15 additions and 11 deletions

View File

@ -41,7 +41,6 @@ version as this will be done internally.
"""
from __future__ import unicode_literals
import cPickle as pickle
import json
import logging
import os
@ -49,6 +48,8 @@ import shutil
from codecs import getwriter
from io import open
import six.moves.cPickle as pickle
from deluge.common import JSON_FORMAT, get_default_config_dir
log = logging.getLogger(__name__)

View File

@ -10,13 +10,13 @@
"""TorrentManager handles Torrent objects"""
from __future__ import unicode_literals
import cPickle as pickle
import datetime
import logging
import operator
import os
import time
import six.moves.cPickle as pickle
from twisted.internet import defer, error, reactor, threads
from twisted.internet.defer import Deferred, DeferredList
from twisted.internet.task import LoopingCall

View File

@ -16,6 +16,8 @@ and subsequently emitted to the clients.
"""
from __future__ import unicode_literals
import six
known_events = {}
@ -29,7 +31,7 @@ class DelugeEventMetaClass(type):
known_events[name] = cls
class DelugeEvent(object):
class DelugeEvent(six.with_metaclass(DelugeEventMetaClass, object)):
"""
The base class for all events.
@ -39,7 +41,6 @@ class DelugeEvent(object):
:type args: list
"""
__metaclass__ = DelugeEventMetaClass
def _get_name(self):
return self.__class__.__name__

View File

@ -18,6 +18,7 @@ import os.path
from functools import wraps
from sys import exc_info
import six
from pkg_resources import resource_filename
@ -44,7 +45,7 @@ def raises_errors_as(error):
return func(self, *args, **kwargs)
except Exception:
(value, tb) = exc_info()[1:]
raise error, value, tb
six.reraise(error, value, tb)
return wrapper
return decorator

View File

@ -10,12 +10,12 @@
from __future__ import unicode_literals
import contextlib
import cPickle as pickle
import logging
import os
import shutil
import sys
import six.moves.cPickle as pickle
from gobject import GError
from gtk import SORT_ASCENDING, Menu, MenuItem, RadioMenuItem, SeparatorMenuItem, clipboard_get, icon_theme_get_default
from gtk.gdk import COLORSPACE_RGB, SELECTION_PRIMARY, Pixbuf, pixbuf_new_from_file, pixbuf_new_from_file_at_size

View File

@ -9,11 +9,11 @@
from __future__ import division, unicode_literals
import cPickle as pickle
import logging
import os.path
import gtk
import six.moves.cPickle as pickle
from gobject import TYPE_UINT64
from gtk.gdk import ACTION_DEFAULT, ACTION_MOVE, BUTTON1_MASK, keyval_name # pylint: disable=ungrouped-imports

View File

@ -9,13 +9,14 @@
from __future__ import unicode_literals
import __builtin__
import gettext
import locale
import logging
import os
import sys
from six.moves import builtins
import deluge.common
log = logging.getLogger(__name__)
@ -28,8 +29,8 @@ def set_dummy_trans(warn_msg=None):
if warn_msg:
log.warn('"%s" has been marked for translation, but translation is unavailable.', txt[0])
return txt[0]
__builtin__.__dict__['_'] = _func
__builtin__.__dict__['ngettext'] = __builtin__.__dict__['_n'] = _func
builtins.__dict__['_'] = _func
builtins.__dict__['ngettext'] = builtins.__dict__['_n'] = _func
def get_translations_path():
@ -127,7 +128,7 @@ def setup_translations(setup_gettext=True, setup_pygtk=False):
kwargs = {} if not deluge.common.PY2 else {'unicode': True}
gettext.install(domain, translations_path, names='ngettext', **kwargs)
__builtin__.__dict__['_n'] = __builtin__.__dict__['ngettext']
builtins.__dict__['_n'] = builtins.__dict__['ngettext']
except Exception as ex:
log.error('Unable to initialize gettext/locale!')
log.exception(ex)