當前位置: 首頁>>代碼示例>>Python>>正文


Python wsxml.MbXmlParser類代碼示例

本文整理匯總了Python中musicbrainz2.wsxml.MbXmlParser的典型用法代碼示例。如果您正苦於以下問題:Python MbXmlParser類的具體用法?Python MbXmlParser怎麽用?Python MbXmlParser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了MbXmlParser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的musicbrainz2.wsxml.MbXmlParser類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。