本文整理汇总了Python中musicbrainz2.wsxml.MbXmlParser.parse方法的典型用法代码示例。如果您正苦于以下问题:Python MbXmlParser.parse方法的具体用法?Python MbXmlParser.parse怎么用?Python MbXmlParser.parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类musicbrainz2.wsxml.MbXmlParser
的用法示例。
在下文中一共展示了MbXmlParser.parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getUserRating
# 需要导入模块: from musicbrainz2.wsxml import MbXmlParser [as 别名]
# 或者: from musicbrainz2.wsxml.MbXmlParser import parse [as 别名]
def getUserRating(self, entityUri):
"""Return the rating a user has applied to an entity.
The given parameter has to be a fully qualified MusicBrainz
ID, as returned by other library functions.
Note that this method only works if a valid user name and
password have been set. Only the rating the authenticated user
applied to the entity will be returned. If username and/or
password are incorrect, an AuthenticationError is raised.
This method will return a L{Rating <musicbrainz2.model.Rating>}
object.
@param entityUri: a string containing an absolute MB ID
@raise ValueError: invalid entityUri
@raise ConnectionError: couldn't connect to server
@raise RequestError: invalid ID or entity
@raise AuthenticationError: invalid user name and/or password
"""
entity = mbutils.extractEntityType(entityUri)
uuid = mbutils.extractUuid(entityUri, entity)
params = { 'entity': entity, 'id': uuid }
stream = self._ws.get('rating', '', filter=params)
try:
parser = MbXmlParser()
result = parser.parse(stream)
except ParseError, e:
raise ResponseError(str(e), e)
示例2: _getFromWebService
# 需要导入模块: from musicbrainz2.wsxml import MbXmlParser [as 别名]
# 或者: from musicbrainz2.wsxml.MbXmlParser import parse [as 别名]
def _getFromWebService(self, entity, id_, include=None, filter=None):
if filter is None:
filterParams = [ ]
else:
filterParams = filter.createParameters()
if include is None:
includeParams = [ ]
else:
includeParams = include.createIncludeTags()
stream = self._ws.get(entity, id_, includeParams, filterParams)
try:
parser = MbXmlParser()
return parser.parse(stream)
except ParseError, e:
raise ResponseError(str(e), e)
示例3: getUserCollection
# 需要导入模块: from musicbrainz2.wsxml import MbXmlParser [as 别名]
# 或者: from musicbrainz2.wsxml.MbXmlParser import parse [as 别名]
def getUserCollection(self, offset=0, maxitems=100):
"""Get the releases that are in a user's collection
A maximum of 100 items will be returned for any one call
to this method. To fetch more than 100 items, use the offset
parameter.
@param offset: the offset to start fetching results from
@param maxitems: the upper limit on items to return
@return: a list of L{musicbrainz2.wsxml.ReleaseResult} objects
@raise ConnectionError: couldn't connect to server
@raise AuthenticationError: invalid user name and/or password
"""
params = { 'offset': offset, 'maxitems': maxitems }
stream = self._ws.get('collection', '', filter=params)
try:
parser = MbXmlParser()
result = parser.parse(stream)
except ParseError, e:
raise ResponseError(str(e), e)