3. base module

This module contains tha base classes for the Musixmatch API generated content:

class Base

Bases: object

The very base (abstract) class of the musixmatch package. I want all classes to implement __str__() and __repr__().

Casting an Base into a str returns a pretty printed (maybe using pprint) string representing the object.

Using repr() on an Base returns an evaluable string representing the instance, whenever it is reasonable.

Base instances are hashable.

classmethod label()

Returns the label that should be used as keyword in the musixmatch.api.JsonResponseMessage body.

classmethod apiMethod()

Returns the musixmatch.api.Method that should be used to build the object. Defaults to label.get where label is the result from label()

class Item(dictionary=None, **keywords)

Bases: musixmatch.base.Base, dict

This is the base class for any entity in musixmatch package. Even if response messages may have XML format, the JSON representation will be the main data format, so the dict sounds like the best base class. It fetches the item data by guessing the musixmatch.api.Method and building the query based on a given keyword argument. Positional argument is meant to be used by collection classes. Use only keyword arguments.

class ItemsCollection(*items)

Bases: musixmatch.base.Base, list

This is the base class for collections of items, like search results, or charts. It behaves like list, but enforce new items to be instance of appropriate class checking against allowedin().

copy()

Returns a shallow copy of the collection.

page(page_index, page_size=3)

Returns a specific page, considering pages that contain “at most” page_size items.

pages(page_size=3)

Returns the number of pages, considering pages that contain “at most” page_size items.

pager(page_size=3)

A generator of pages, considering pages that contain “at most” page_size items.

paged(page_size=3)

Returns self, paged by page_size. That is, a list of sub-collections which contain “at most” page_size items.

classmethod fromResponseMessage(message)

Returns an object instance, built on a musixmatch.api.ResponseMessage

classmethod allowedin()

Returns the allowed content class. Defaults to Item

Previous topic

2. WS module

Next topic

4. artist module

This Page