Package musicbrainz2 :: Module model :: Class Entity
[frames | no frames]

Type Entity

object --+
         |
        Entity

Known Subclasses:
Artist, Release, Track

A first-level MusicBrainz class.

All entities in MusicBrainz have unique IDs (which are absolute URIs) and may have any number of relations to other entities. This class is abstract and should not be instantiated.

Relations are differentiated by their target type, that means, where they link to. MusicBrainz currently supports four target types (artists, releases, tracks, and URLs) each identified using a URI. To get all relations with a specific target type, you can use getRelations and pass one of the following constants as the parameter:

See Also: Relation

Method Summary
  __init__(self, id_)
Constructor.
  addRelation(self, relation)
Adds a relation.
  getId(self)
Returns a MusicBrainz ID.
  getRelations(self, targetType, relationType, requiredAttributes, direction)
Returns a list of relations.
  getRelationTargets(self, targetType, relationType, requiredAttributes, direction)
Returns a list of relation targets.
  getRelationTargetTypes(self)
Returns a list of target types available for this entity.
  setId(self, value)
Sets a MusicBrainz ID.
    Inherited from object
  __delattr__(...)
x.__delattr__('name') <==> del x.name
  __getattribute__(...)
x.__getattribute__('name') <==> x.name
  __hash__(x)
x.__hash__() <==> hash(x)
  __new__(T, S, ...)
T.__new__(S, ...) -> a new object with type S, a subtype of T
  __reduce__(...)
helper for pickle
  __reduce_ex__(...)
helper for pickle
  __repr__(x)
x.__repr__() <==> repr(x)
  __setattr__(...)
x.__setattr__('name', value) <==> x.name = value
  __str__(x)
x.__str__() <==> str(x)

Property Summary
  id: The MusicBrainz ID.

Method Details

__init__(self, id_=None)
(Constructor)

Constructor.

This should only used by derived classes.
Parameters:
id_ - a string containing an absolute URI
Overrides:
__builtin__.object.__init__

addRelation(self, relation)

Adds a relation.

This method adds relation to the list of relations. The given relation has to be initialized, at least the target type has to be set.
Parameters:
relation - the Relation object to add

See Also: Entity

getId(self)

Returns a MusicBrainz ID.
Returns:
a string containing a URI, or None

getRelations(self, targetType=None, relationType=None, requiredAttributes=(), direction=None)

Returns a list of relations.

If targetType is given, only relations of that target type are returned. For MusicBrainz, the following target types are defined:

If targetType is Relation.TO_ARTIST, for example, this method returns all relations between this Entity and artists.

You may use the relationType parameter to further restrict the selection. If it is set, only relations with the given relation type are returned. The requiredAttributes sequence lists attributes that have to be part of all returned relations.

If direction is set, only relations with the given reading direction are returned. You can use the Relation.DIR_FORWARD, Relation.DIR_BACKWARD, and Relation.DIR_BOTH constants for this.
Parameters:
targetType - a string containing an absolute URI, or None
relationType - a string containing an absolute URI, or None
requiredAttributes - a sequence containing absolute URIs
direction - one of Relation's direction constants
Returns:
a list of Relation objects

See Also: Entity

getRelationTargets(self, targetType=None, relationType=None, requiredAttributes=(), direction=None)

Returns a list of relation targets.

The arguments work exactly like in getRelations, but instead of Relation objects, the matching relation targets are returned. This can be Artist, Release, or Track objects, depending on the relations.

As a special case, URL strings are returned if the target is an URL.
Parameters:
targetType - a string containing an absolute URI, or None
relationType - a string containing an absolute URI, or None
requiredAttributes - a sequence containing absolute URIs
direction - one of Relation's direction constants
Returns:
a list of objects, depending on the relation

See Also: getRelations

getRelationTargetTypes(self)

Returns a list of target types available for this entity.

Use this to find out to which types of targets this entity has relations. If the entity only has relations to tracks and artists, for example, then a list containg the strings Relation.TO_TRACK and Relation.TO_ARTIST is returned.
Returns:
a list of strings containing URIs

See Also: getRelations

setId(self, value)

Sets a MusicBrainz ID.
Parameters:
value - a string containing an absolute URI

Property Details

id

The MusicBrainz ID.
Get Method:
getId(self)
Set Method:
setId(self, value)

Generated by Epydoc 2.1 on Wed Dec 20 18:19:28 2006 http://epydoc.sf.net