本文整理汇总了Python中musicbrainz2.wsxml.MbXmlParser类的典型用法代码示例。如果您正苦于以下问题:Python MbXmlParser类的具体用法?Python MbXmlParser怎么用?Python MbXmlParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MbXmlParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: testReleaseFull
def testReleaseFull(self):
f = os.path.join(VALID_RELEASE_DIR, 'Little_Earthquakes_2.xml')
md = MbXmlParser().parse(f)
release = md.getRelease()
self.failIf( release is None )
self.assertEquals(release.getId(),
makeId('02232360-337e-4a3f-ad20-6cdd4c34288c'))
self.assertEquals(release.getArtist().getName(), 'Tori Amos')
events = release.getReleaseEventsAsDict()
self.assertEquals(len(events), 3)
self.assertEquals(events['GB'], '1992-01-13')
self.assertEquals(events['DE'], '1992-01-17')
self.assertEquals(events['US'], '1992-02-25')
date = release.getEarliestReleaseDate()
self.assertEquals(date, '1992-01-13')
event = release.getEarliestReleaseEvent()
self.assertEquals(event.date, date)
self.assertEquals(event.country, 'GB')
discs = release.getDiscs()
self.assertEquals(len(discs), 3)
self.assertEquals(discs[0].getId(), 'ILKp3.bZmvoMO7wSrq1cw7WatfA-')
self.assertEquals(discs[1].getId(), 'ejdrdtX1ZyvCb0g6vfJejVaLIK8-')
self.assertEquals(discs[2].getId(), 'Y96eDQZbF4Z26Y5.Sxdbh3wGypo-')
tracks = release.getTracks()
self.assertEquals(len(tracks), 12)
self.assertEquals(tracks[0].getTitle(), 'Crucify')
self.assertEquals(tracks[4].getTitle(), 'Winter')
开发者ID:bh0085,项目名称:programming,代码行数:33,代码来源:test_wsxml_release.py
示例2: testReleaseGroupFull
def testReleaseGroupFull(self):
f = os.path.join(RELEASEGROUP_DIR, 'The_Cure_1.xml')
md = MbXmlParser().parse(f)
releaseGroup = md.getReleaseGroup()
self.failIf(releaseGroup is None)
releases = releaseGroup.getReleases()
self.failIf(releases is None)
self.assertEquals(len(releases), 4)
# Check releases, which are in no particular order.
expectedIds = [
'd984e1a3-7281-46bb-ad8b-1478a00f2fbf',
'c100a398-3132-48a8-a5fc-c3e908ac17dc',
'24bec892-b21d-47d8-a288-dc6450152574',
'61a4ec51-fa34-4757-85d7-83231776ed14']
actualIds = [release.id[-36:] for release in releases]
for expectedId in expectedIds:
self.assert_(expectedId in actualIds)
# Check artist
self.assertEquals(releaseGroup.getArtist().getName(), 'The Cure')
self.assertEquals(releaseGroup.getArtist().id[-36:],
'69ee3720-a7cb-4402-b48d-a02c366f2bcf')
开发者ID:apotapov,项目名称:musicproject,代码行数:25,代码来源:test_wsxml_releasegroup.py
示例3: testTrackFull
def testTrackFull(self):
f = os.path.join(VALID_TRACK_DIR, 'Silent_All_These_Years_4.xml')
md = MbXmlParser().parse(f)
track = md.getTrack()
self.failIf( track is None )
self.assertEquals(track.getTitle(), 'Silent All These Years')
self.assertEquals(track.getDuration(), 253466)
artist = track.getArtist()
self.failIf( artist is None )
self.assertEquals(artist.getId(),
makeId('c0b2500e-0cef-4130-869d-732b23ed9df5', 'artist'))
self.assertEquals(artist.getType(), NS_MMD_1 + 'Person')
self.assertEquals(artist.getName(), 'Tori Amos')
self.assertEquals(artist.getSortName(), 'Amos, Tori')
puids = track.getPuids()
self.assertEquals(len(puids), 7)
self.assertEquals(puids[0], 'c2a2cee5-a8ca-4f89-a092-c3e1e65ab7e6')
self.assertEquals(puids[6], '42ab76ea-5d42-4259-85d7-e7f2c69e4485')
isrcs = track.isrcs
self.assertEquals(len(isrcs), 1)
self.assertEquals(isrcs[0], 'USPR37300012')
releases = track.getReleases()
self.assertEquals(len(releases), 1)
self.assertEquals(releases[0].getTitle(), 'Little Earthquakes')
self.assertEquals(releases[0].getTracksOffset(), 2)
开发者ID:apotapov,项目名称:musicproject,代码行数:30,代码来源:test_wsxml_track.py
示例4: testSearchResults
def testSearchResults(self):
f = os.path.join(RELEASEGROUP_DIR, 'search_result_1.xml')
md = MbXmlParser().parse(f)
releaseGroups = md.getReleaseGroupResults()
self.failIf(releaseGroups is None)
self.assertEquals(md.getReleaseGroupResultsOffset(), 0)
self.assertEquals(md.getReleaseGroupResultsCount(), 3)
expectedEntries = {
'963eac15-e3da-3a92-aa5c-2ec23bfb6ec2': ['Signal Morning', 100],
'0bd324a3-1c90-3bdb-8ca4-4101a580c62c': ['Circulatory System', 98],
'ea7d8352-7751-30be-8490-bb6df737f47c': ['Inside Views', 90]}
for result in releaseGroups:
releaseGroup = result.releaseGroup
self.failIf(releaseGroup is None)
releaseGroupId = releaseGroup.id[-36:]
self.assert_(releaseGroupId in expectedEntries)
expectedTitle, expectedScore = expectedEntries[releaseGroupId]
self.assertEquals(releaseGroup.title, expectedTitle)
self.assertEquals(result.score, expectedScore)
del expectedEntries[releaseGroupId]
开发者ID:apotapov,项目名称:musicproject,代码行数:25,代码来源:test_wsxml_releasegroup.py
示例5: getUserRating
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)
开发者ID:apotapov,项目名称:musicproject,代码行数:31,代码来源:webservice.py
示例6: testTrackBasic
def testTrackBasic(self):
f = os.path.join(VALID_TRACK_DIR, 'Silent_All_These_Years_1.xml')
md = MbXmlParser().parse(f)
track = md.getTrack()
self.failIf( track is None )
self.assertEquals(track.getTitle(), 'Silent All These Years')
self.assertEquals(track.getDuration(), 253466)
开发者ID:apotapov,项目名称:musicproject,代码行数:8,代码来源:test_wsxml_track.py
示例7: testTags
def testTags(self):
f = os.path.join(VALID_LABEL_DIR, 'Atlantic_Records_3.xml')
md = MbXmlParser().parse(f)
label = md.getLabel()
self.failIf( label is None )
self.assertEquals(label.getTag('american').count, None)
self.assertEquals(label.getTag('jazz').count, None)
self.assertEquals(label.getTag('blues').count, None)
开发者ID:apotapov,项目名称:musicproject,代码行数:9,代码来源:test_wsxml_label.py
示例8: testIncomplete
def testIncomplete(self):
f = os.path.join(VALID_LABEL_DIR, 'Atlantic_Records_3.xml')
md = MbXmlParser().parse(f)
label = md.getLabel()
self.failIf( label is None )
self.assertEquals(label.id,
makeId('50c384a2-0b44-401b-b893-8181173339c7'))
self.assertEquals(label.code, None)
开发者ID:apotapov,项目名称:musicproject,代码行数:9,代码来源:test_wsxml_label.py
示例9: testTags
def testTags(self):
f = os.path.join(VALID_ARTIST_DIR, 'Tchaikovsky-2.xml')
md = MbXmlParser().parse(f)
artist = md.getArtist()
self.failIf( artist is None )
self.assertEquals(artist.getTag('classical').count, 100)
self.assertEquals(artist.getTag('russian').count, 60)
self.assertEquals(artist.getTag('romantic era').count, 40)
self.assertEquals(artist.getTag('composer').count, 120)
开发者ID:bh0085,项目名称:programming,代码行数:10,代码来源:test_wsxml_artist.py
示例10: testArtistBasic
def testArtistBasic(self):
f = os.path.join(VALID_ARTIST_DIR, 'Tori_Amos_1.xml')
md = MbXmlParser().parse(f)
artist = md.getArtist()
self.failIf( artist is None )
self.assertEquals(artist.getName(), 'Tori Amos')
self.assertEquals(artist.getSortName(), 'Amos, Tori')
self.assertEquals(artist.getBeginDate(), '1963-08-22')
self.assertEquals(len(artist.getReleases()), 0)
开发者ID:bh0085,项目名称:programming,代码行数:10,代码来源:test_wsxml_artist.py
示例11: testReleaseGroupBasic
def testReleaseGroupBasic(self):
f = os.path.join(RELEASEGROUP_DIR, 'The_Cure_1.xml')
md = MbXmlParser().parse(f)
releaseGroup = md.getReleaseGroup()
self.failIf(releaseGroup is None)
self.assertEquals(releaseGroup.getId(),
makeId('c6a62b78-70f7-44f7-b159-064f6b7ba03a'))
self.assertEquals(releaseGroup.getTitle(), 'The Cure')
self.assertEquals(releaseGroup.getType(), NS_MMD_1 + 'Album')
开发者ID:apotapov,项目名称:musicproject,代码行数:10,代码来源:test_wsxml_releasegroup.py
示例12: testTags
def testTags(self):
f = os.path.join(VALID_RELEASE_DIR, 'Highway_61_Revisited_2.xml')
md = MbXmlParser().parse(f)
release = md.getRelease()
self.failIf( release is None )
self.assertEquals(release.getTag('rock').count, 100)
self.assertEquals(release.getTag('blues rock').count, 40)
self.assertEquals(release.getTag('folk rock').count, 40)
self.assertEquals(release.getTag('dylan').count, 4)
开发者ID:bh0085,项目名称:programming,代码行数:10,代码来源:test_wsxml_release.py
示例13: testIncompleteReleaseEvent
def testIncompleteReleaseEvent(self):
f = os.path.join(VALID_RELEASE_DIR, 'Under_the_Pink_1.xml')
md = MbXmlParser().parse(f)
release = md.getRelease()
self.failIf( release is None )
self.assertEquals(release.getTitle(), 'Under the Pink')
events = release.getReleaseEvents()
self.assertEquals(len(events), 1)
self.assertEquals(events[0].getDate(), '1994-01-28')
开发者ID:bh0085,项目名称:programming,代码行数:11,代码来源:test_wsxml_release.py
示例14: testSearchResults
def testSearchResults(self):
f = os.path.join(VALID_TRACK_DIR, 'search_result_1.xml')
md = MbXmlParser().parse(f)
self.assertEquals(md.trackResultsOffset, 7)
self.assertEquals(md.trackResultsCount, 100)
results = md.getTrackResults()
self.assertEquals(len(results), 3)
self.assertEquals(results[0].getScore(), 100)
track1 = results[0].getTrack()
self.assertEquals(track1.getTitle(), 'Little Earthquakes')
开发者ID:apotapov,项目名称:musicproject,代码行数:13,代码来源:test_wsxml_track.py
示例15: testReleaseGroup
def testReleaseGroup(self):
f = os.path.join(VALID_RELEASE_DIR, 'Under_the_Pink_2.xml')
md = MbXmlParser().parse(f)
release = md.getRelease()
self.failIf(release is None)
self.assertEquals(release.getTitle(), 'Under the Pink')
releaseGroup = release.getReleaseGroup()
self.failIf(releaseGroup is None)
self.assertEquals(releaseGroup.id[-36:],
'ef2b891f-ca73-3e14-b38b-a68699dab8c4')
self.assertEquals(releaseGroup.getTitle(), 'Under the Pink')
self.assertEquals(releaseGroup.getType(), NS_MMD_1 + 'Album')
开发者ID:apotapov,项目名称:musicproject,代码行数:14,代码来源:test_wsxml_release.py
示例16: testLabelBasic
def testLabelBasic(self):
f = os.path.join(VALID_LABEL_DIR, 'Atlantic_Records_1.xml')
md = MbXmlParser().parse(f)
label = md.getLabel()
self.failIf( label is None )
self.assertEquals(label.id,
makeId('50c384a2-0b44-401b-b893-8181173339c7'))
self.assertEquals(label.type, NS_MMD_1 + 'OriginalProduction')
self.assertEquals(label.name, 'Atlantic Records')
self.assertEquals(label.beginDate, '1947')
self.assertEquals(label.endDate, None)
self.assertEquals(label.country, 'US')
self.assertEquals(label.code, '121')
开发者ID:apotapov,项目名称:musicproject,代码行数:14,代码来源:test_wsxml_label.py
示例17: testReleaseBasic
def testReleaseBasic(self):
f = os.path.join(VALID_RELEASE_DIR, 'Little_Earthquakes_1.xml')
md = MbXmlParser().parse(f)
release = md.getRelease()
self.failIf( release is None )
self.assertEquals(release.getId(),
makeId('02232360-337e-4a3f-ad20-6cdd4c34288c'))
self.assertEquals(release.getTitle(), 'Little Earthquakes')
self.assertEquals(release.getTextLanguage(), 'ENG')
self.assertEquals(release.getTextScript(), 'Latn')
self.assertEquals(len(release.getTypes()), 2)
self.assert_(NS_MMD_1 + 'Album' in release.getTypes())
self.assert_(NS_MMD_1 + 'Official' in release.getTypes())
开发者ID:bh0085,项目名称:programming,代码行数:15,代码来源:test_wsxml_release.py
示例18: testUser
def testUser(self):
f = os.path.join(VALID_USER_DIR, 'User_1.xml')
md = MbXmlParser().parse(f)
userList = md.getUserList()
self.assertEquals(len(userList), 1)
user = userList[0]
self.failIf( user is None )
self.assertEquals(user.getName(), 'matt')
self.assertEquals(user.getShowNag(), False)
types = user.getTypes()
self.assertEquals(len(types), 2)
self.assert_( NS_EXT_1 + 'AutoEditor' in types )
self.assert_( NS_EXT_1 + 'RelationshipEditor' in types )
开发者ID:apotapov,项目名称:musicproject,代码行数:16,代码来源:test_wsxml_user.py
示例19: testReleaseRelations
def testReleaseRelations(self):
f = os.path.join(VALID_RELEASE_DIR, 'Highway_61_Revisited_1.xml')
md = MbXmlParser().parse(f)
release = md.getRelease()
self.failIf( release is None )
self.assertEquals(release.getId(),
makeId('d61a2bd9-81ac-4023-bd22-1c884d4a176c'))
(rel1, rel2) = release.getRelations(Relation.TO_URL)
self.assertEquals(rel1.getTargetId(),
'http://en.wikipedia.org/wiki/Highway_61_Revisited')
self.assertEquals(rel1.getDirection(), Relation.DIR_NONE)
self.assertEquals(rel2.getTargetId(),
'http://www.amazon.com/gp/product/B0000024SI')
开发者ID:bh0085,项目名称:programming,代码行数:16,代码来源:test_wsxml_release.py
示例20: _getFromWebService
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)
开发者ID:apotapov,项目名称:musicproject,代码行数:17,代码来源:webservice.py
注:本文中的musicbrainz2.wsxml.MbXmlParser类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论