def encode(self): t = self.original if t.is_loaded(): return { u"id": unicode(Link.from_playlist(t)), u"status": u"", u"name": unicode(t.name(), "utf-8"), u"tracks": [simplify(x) for x in t], } else: return {u"id": u"unknown", u"status": u"", u"name": u"Loading...", u"tracks": []}
def test_simplify(self): f = Frob("qux", "quux", "corge") self.assertEqual(simplify(f), {u'baz': u'corge', u'foo': u'qux', u'bar': u'quux'})
def _simplify(o): try: return simplify(o) except ValueError: return o