PKC playqueues now log as dicts for pprint

This commit is contained in:
tomkat83 2017-12-28 17:32:58 +01:00
parent 771520cd96
commit e358e9b3a5

View file

@ -47,18 +47,19 @@ class PlaylistObjectBaseclase(object):
""" """
Print the playlist, e.g. to log Print the playlist, e.g. to log
""" """
answ = "<%s: " % (self.__class__.__name__) answ = '{\'%s\': {' % (self.__class__.__name__)
# For some reason, can't use dir directly # For some reason, can't use dir directly
answ += "id: %s, " % self.id answ += '\'id\': %s, ' % self.id
answ += "items: %s, " % self.items
for key in self.__dict__: for key in self.__dict__:
if key not in ("id", 'items'): if key in ('id', 'items', 'kodi_pl'):
if type(getattr(self, key)) in (str, unicode): continue
answ += '%s: %s, ' % (key, tryEncode(getattr(self, key))) if isinstance(getattr(self, key), (str, unicode)):
answ += '\'%s\': \'%s\', ' % (key,
tryEncode(getattr(self, key)))
else: else:
# e.g. int # e.g. int
answ += '%s: %s, ' % (key, str(getattr(self, key))) answ += '\'%s\': %s, ' % (key, str(getattr(self, key)))
return answ[:-2] + ">" return answ + '\'items\': %s}}' % self.items
def clear(self): def clear(self):
""" """
@ -141,14 +142,23 @@ class Playlist_Item(object):
""" """
Print the playlist item, e.g. to log Print the playlist item, e.g. to log
""" """
answ = "<%s: " % (self.__class__.__name__) answ = '{\'%s\': {' % (self.__class__.__name__)
answ += '\'id\': %s, ' % self.id
answ += '\'plex_id\': %s, ' % self.plex_id
for key in self.__dict__: for key in self.__dict__:
if type(getattr(self, key)) in (str, unicode): if key in ('id', 'plex_id', 'xml'):
answ += '%s: %s, ' % (key, tryEncode(getattr(self, key))) continue
if isinstance(getattr(self, key), (str, unicode)):
answ += '\'%s\': \'%s\', ' % (key,
tryEncode(getattr(self, key)))
else: else:
# e.g. int # e.g. int
answ += '%s: %s, ' % (key, str(getattr(self, key))) answ += '\'%s\': %s, ' % (key, str(getattr(self, key)))
return answ[:-2] + ">" if self.xml is None:
answ += '\'xml\': None}}'
else:
answ += '\'xml\': \'%s\'}}' % self.xml.tag
return answ
def plex_stream_index(self, kodi_stream_index, stream_type): def plex_stream_index(self, kodi_stream_index, stream_type):
""" """