From 4b4dc1afbf2545480c9328e17830a2c6f9cf551b Mon Sep 17 00:00:00 2001 From: croneter Date: Fri, 18 Dec 2020 19:59:33 +0100 Subject: [PATCH] Fix class __repr__ to account for Python 3 --- resources/lib/library_sync/sections.py | 3 +-- resources/lib/playlist_func.py | 11 ++--------- resources/lib/playlists/common.py | 8 +------- resources/lib/utils.py | 5 +---- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/resources/lib/library_sync/sections.py b/resources/lib/library_sync/sections.py index e538aaa4..77a65b3d 100644 --- a/resources/lib/library_sync/sections.py +++ b/resources/lib/library_sync/sections.py @@ -94,8 +94,7 @@ class Section(object): "'section_type': '{self.section_type}', " "'sync_to_kodi': {self.sync_to_kodi}, " "'last_sync': {self.last_sync}" - "}}").format(self=self).encode('utf-8') - __str__ = __repr__ + "}}").format(self=self) def __bool__(self): return (self.section_id is not None and diff --git a/resources/lib/playlist_func.py b/resources/lib/playlist_func.py index 3c792535..29e9f1cf 100644 --- a/resources/lib/playlist_func.py +++ b/resources/lib/playlist_func.py @@ -86,12 +86,8 @@ class Playqueue_Object(object): "'repeat': {self.repeat}, " "'kodi_playlist_playback': {self.kodi_playlist_playback}, " "'pkc_edit': {self.pkc_edit}, ".format(self=self)) - answ = answ.encode('utf-8') # Since list.__repr__ will return string, not unicode - return answ + b"'items': {self.items}}}".format(self=self) - - def __str__(self): - return self.__repr__() + return answ + "'items': {self.items}}}".format(self=self) def is_pkc_clear(self): """ @@ -201,7 +197,7 @@ class PlaylistItem(object): def uri(self): return self._uri - def __unicode__(self): + def __repr__(self): return ("{{" "'id': {self.id}, " "'plex_id': {self.plex_id}, " @@ -217,9 +213,6 @@ class PlaylistItem(object): "'force_transcode': {self.force_transcode}, " "'part': {self.part}".format(self=self)) - def __repr__(self): - return self.__unicode__().encode('utf-8') - def plex_stream_index(self, kodi_stream_index, stream_type): """ Pass in the kodi_stream_index [int] in order to receive the Plex stream diff --git a/resources/lib/playlists/common.py b/resources/lib/playlists/common.py index 6de02688..1ebd4ab2 100644 --- a/resources/lib/playlists/common.py +++ b/resources/lib/playlists/common.py @@ -64,7 +64,7 @@ class Playlist(object): self.kodi_type = None self.kodi_hash = None - def __unicode__(self): + def __repr__(self): return ("{{" "'plex_id': {self.plex_id}, " "'plex_name': '{self.plex_name}', " @@ -75,12 +75,6 @@ class Playlist(object): "'kodi_hash': '{self.kodi_hash}'" "}}").format(self=self) - def __repr__(self): - return self.__unicode__().encode('utf-8') - - def __str__(self): - return self.__repr__() - def __bool__(self): return (self.plex_id and self.plex_updatedat and self.plex_name and self._kodi_path and self.kodi_filename and self.kodi_type and diff --git a/resources/lib/utils.py b/resources/lib/utils.py index 7be43869..70da790d 100644 --- a/resources/lib/utils.py +++ b/resources/lib/utils.py @@ -267,14 +267,11 @@ class AttributeDict(dict): def __setattr__(self, attr, value): self[attr] = value - def __unicode__(self): + def __repr__(self): return '<{0}:{1}:{2}>'.format(self.__class__.__name__, self.id, self.get('title', 'None')) - def __repr__(self): - return self.__unicode__().encode('utf-8') - def cast(func, value): """