Skip to content

Commit

Permalink
Fixed Python 3 compatibility issues
Browse files Browse the repository at this point in the history
  • Loading branch information
fuzeman committed Jul 1, 2016
1 parent 85bdb55 commit 29122ec
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions plex/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from plex.helpers import has_attribute
from plex.interfaces import construct_map
from plex.interfaces.core.base import InterfaceProxy
from plex.lib.six import add_metaclass
from plex.lib import six as six
from plex.objects.core.manager import ObjectManager

import logging
Expand Down Expand Up @@ -107,7 +107,7 @@ def __getitem__(self, key):
return self.client[key]


@add_metaclass(PlexMeta)
@six.add_metaclass(PlexMeta)
class Plex(object):
_client = None

Expand Down
4 changes: 2 additions & 2 deletions plex/core/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# :copyright: (c) 2014 by Armin Ronacher.
# :license: BSD, see LICENSE for more details.

from plex.lib.six import reraise
from plex.lib import six as six

import os
import sys
Expand Down Expand Up @@ -63,7 +63,7 @@ def load_module(self, fullname):
# we swallow it and try the next choice. The skipped frame
# is the one from __import__ above which we don't care about
if self.is_important_traceback(realname, tb):
reraise(exc_type, exc_value, tb.tb_next)
six.reraise(exc_type, exc_value, tb.tb_next)
continue
module = sys.modules[fullname] = sys.modules[realname]
if '.' not in modname:
Expand Down
12 changes: 6 additions & 6 deletions plex/core/idict.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from plex.lib.six import string_types
from plex.lib import six as six

class idict(dict):
def __init__(self, initial=None):
if initial:
self.update(initial)

def get(self, k, d=None):
if isinstance(k, string_types):
if isinstance(k, six.string_types):
k = k.lower()

if super(idict, self).__contains__(k):
Expand All @@ -30,25 +30,25 @@ def update(self, E=None, **F):
self[k] = F[k]

def __contains__(self, k):
if isinstance(k, string_types):
if isinstance(k, six.string_types):
k = k.lower()

return super(idict, self).__contains__(k)

def __delitem__(self, k):
if isinstance(k, string_types):
if isinstance(k, six.string_types):
k = k.lower()

super(idict, self).__delitem__(k)

def __getitem__(self, k):
if isinstance(k, string_types):
if isinstance(k, six.string_types):
k = k.lower()

return super(idict, self).__getitem__(k)

def __setitem__(self, k, value):
if isinstance(k, string_types):
if isinstance(k, six.string_types):
k = k.lower()

super(idict, self).__setitem__(k, value)
5 changes: 3 additions & 2 deletions plex/interfaces/core/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from plex.lib.six import string_types, StringIO
from plex.lib import six
from plex.lib.six import StringIO
from plex.lib.six.moves.urllib_parse import urlparse

from functools import wraps
Expand Down Expand Up @@ -172,7 +173,7 @@ def __construct(cls, client, path, node, schema):
else:
descriptor = item

if isinstance(descriptor, string_types):
if isinstance(descriptor, six.string_types):
if descriptor not in cls.object_map:
raise Exception('Unable to find descriptor by name "%s"' % descriptor)

Expand Down
6 changes: 3 additions & 3 deletions plex/objects/core/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from plex.lib.six import add_metaclass
from plex.lib import six as six
from plex.interfaces.core.base import Interface

import collections
Expand Down Expand Up @@ -47,7 +47,7 @@ def value_convert(self, value):
try:
result = target_type(result)
except Exception as ex:
raise ex, None, sys.exc_info()[2]
six.reraise(ex, None, sys.exc_info()[2])

return result

Expand All @@ -71,7 +71,7 @@ def __init__(self, name, bases, attrs):
Interface.object_map[self.__name__] = self


@add_metaclass(DescriptorMeta)
@six.add_metaclass(DescriptorMeta)
class Descriptor(Interface):
attribute_map = None

Expand Down
2 changes: 1 addition & 1 deletion plex/objects/core/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def load(cls):
try:
mod = __import__(name, fromlist=['*'])
except Exception as ex:
log.warn('Unable to import "%s" - %s', name, ex)
log.warn('Unable to import "%s" - %s', name, ex, exc_info=True)
continue

# Get classes in module
Expand Down

0 comments on commit 29122ec

Please sign in to comment.