Esempio n. 1
0
 def testArtistRelationRef(self):
   # test if 2 calls to the same artist return the same reference
   Factories.clear()
   artistA = ArtistFactory.get(self.artistA)
   artistB = ArtistFactory.get(self.artistB)
   artist_relationA = ArtistRelationFactory.get(artistA, artistB)
   artist_relationA.test = self.artist_relation_test
   artist_relationB = ArtistRelationFactory.get(artistA, artistB)
   self.assertEqual(artist_relationA.test, artist_relationB.test)
Esempio n. 2
0
  def testArtistRelationClear(self):
    Factories.clear()
    artistA = ArtistFactory.get(self.artistA)
    artistB = ArtistFactory.get(self.artistB)
    artist_relation = ArtistRelationFactory.get(artistA, artistB)
    artist_relation.test = self.artist_relation_test
    self.assertEqual(artist_relation.test, self.artist_relation_test)

    Factories.clear()
    artistA = ArtistFactory.get(self.artistA)
    artistB = ArtistFactory.get(self.artistB)
    artist_relation = ArtistRelationFactory.get(artistA, artistB)
    self.assertNotEqual(artist_relation.test, self.artist_relation_test)
Esempio n. 3
0
  def testArtistRelationPickle(self):
    Factories.clear()
    artistA = ArtistFactory.get(self.artistA)
    artistB = ArtistFactory.get(self.artistB)
    artist_relation = ArtistRelationFactory.get(artistA, artistB)
    artist_relation.test = self.artist_relation_test

    state = pickle.dumps(Factories.getstate())
    Factories.clear()
    pickle.loads(state)

    artistA = ArtistFactory.get(self.artistA)
    artistB = ArtistFactory.get(self.artistB)
    artist_relation = ArtistRelationFactory.get(artistA, artistB)
    artist_relation.test = self.artist_relation_test
    self.assertEqual(artist_relation.test, self.artist_relation_test)
Esempio n. 4
0
File: library.py Progetto: pscn/ads
 def _similar_artists(self, artist_nameA, artist_nameB, match, source,
     locked=False):
   if not locked: self.acquire()
   #self._logger.debug(u"%s: [%s]-[%s] %2.2f" % (source, artist_nameA,
   #    artist_nameB, match))
   artistA = ArtistFactory.by_key(artist_nameA)
   artistB = ArtistFactory.by_key(artist_nameB)
   #if not artistA: self._logger.debug(u"similar_artists[%s]: not found" %
   #    artist_nameA)
   #if not artistB: self._logger.debug(u"similar_artists[%s]: not found" %
   #    artist_nameB)
   if artistA and artistB:
     relation = ArtistRelationFactory.get(artistA, artistB)
     old_rating = relation.rating
     relation.rate(0.75 + 0.25 * match)
     self._logger.debug(u"%s [%s]-[%s] m(%2.2f) r(%2.2f|%2.2f)" % (source,
         artistA, artistB, match, relation.rating, old_rating))
     if self._queue_lookup_results:
       if self._lastfm:
         self._lastfm.similar_artists_low(self.similar_artists, artist_nameB,
             self._thres_lastfm_lookup)
       if self._echonest:
         self._echonest.similar_artists_low(self.similar_artists, artist_nameB,
             self._thres_lastfm_lookup)
   if not locked: self.release()
Esempio n. 5
0
 def __init__(self, trackA, trackB):
   self.trackA = trackA
   self.trackB = trackB
   self.ratingref = RatingFactory.get(0.7, 1.0)
   self.artistRelation = ArtistRelationFactory.get(trackA.artist, trackB.artist)
   self.lastused = now()
   TrackRelationFactory.save(self)