def de_json(cls, data: dict, client: 'Client') -> Optional['Album']: """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music. Returns: :obj:`yandex_music.Album`: Альбом. """ if not data: return None data = super(Album, cls).de_json(data, client) from yandex_music import Artist, Label, TrackPosition, Track, Deprecation data['artists'] = Artist.de_list(data.get('artists'), client) data['labels'] = Label.de_list(data.get('labels'), client) data['track_position'] = TrackPosition.de_json( data.get('track_position'), client) data['duplicates'] = Album.de_list(data.get('duplicates'), client) data['albums'] = Album.de_list(data.get('albums'), client) data['deprecation'] = Deprecation.de_json(data.get('deprecation'), client) if data.get('volumes'): data['volumes'] = [ Track.de_list(i, client) for i in data['volumes'] ] return cls(client=client, **data)
def de_json(cls, data, client): """Десериализация объекта. Args: data (:obj:`dict`): Поля и значения десериализуемого объекта. client (:obj:`yandex_music.Client`): Объект класса :class:`yandex_music.Client`, представляющий клиент Yandex Music. Returns: :obj:`yandex_music.Album`: Объект класса :class:`yandex_music.Album`. """ if not data: return None data = super(Album, cls).de_json(data, client) from yandex_music import Artist, Label, TrackPosition, Track data['artists'] = Artist.de_list(data.get('artists'), client) data['labels'] = Label.de_list(data.get('labels'), client) data['track_position'] = TrackPosition.de_json( data.get('track_position'), client) if data.get('volumes'): data['volumes'] = [ Track.de_list(i, client) for i in data['volumes'] ] return cls(client=client, **data)
def de_json(cls, data, client): if not data: return None data = super(Album, cls).de_json(data, client) from yandex_music import Artist, Label, TrackPosition data['artists'] = Artist.de_list(data.get('artists'), client) data['labels'] = Label.de_list(data.get('labels'), client) data['track_position'] = TrackPosition.de_json(data.get('track_position'), client) return cls(client=client, **data)
def de_json(cls, data: dict, client: 'Client') -> Optional['Album']: if not data: return None data = super(Album, cls).de_json(data, client) from yandex_music import Artist, Label, TrackPosition, Track data['artists'] = Artist.de_list(data.get('artists'), client) data['labels'] = Label.de_list(data.get('labels'), client) data['track_position'] = TrackPosition.de_json( data.get('track_position'), client) if data.get('volumes'): data['volumes'] = [ Track.de_list(i, client) for i in data['volumes'] ] return cls(client=client, **data)
def test_de_list_none(self, client): assert Label.de_list({}, client) == []