Example #1
0
 def _score(cls, t: DidlMusicTrack, song: AudioFile) -> float:
     d = t.to_dict()
     try:
         person = song.list("~people")[0]
     except IndexError:
         person = None
     album = song("album")
     score = (int(
         remove_punctuation(t.title).lower() == remove_punctuation(
             song("title")).lower()) +
              int(bool(person) and person in d.values()) +
              int(bool(album) and album in d.get("album", "")))
     if cls.DEBUG:
         print_d("%.1f for %s (%s)" % (score, t.title, d))
     return score
Example #2
0
 def get_key(cls, song):
     key = song(cls.get_key_expression())
     if cls.config_get_bool(cls._CFG_REMOVE_DIACRITICS):
         key = remove_diacritics(key)
     if cls.config_get_bool(cls._CFG_CASE_INSENSITIVE):
         key = key.lower()
     if cls.config_get_bool(cls._CFG_REMOVE_PUNCTUATION):
         key = remove_punctuation(key)
     if cls.config_get_bool(cls._CFG_REMOVE_WHITESPACE):
         key = "_".join(key.split())
     return key
 def test_unicode(self):
     assert remove_punctuation("†one⁋two\u2003three") == "onetwo\u2003three"
 def test_harder(self):
     assert remove_punctuation("\"abc\" '123' ?!") == "abc 123 "
     assert remove_punctuation(SOME_FRENCH) == "goût dœufs à Noël"
 def test_empty(self):
     assert remove_punctuation("") == ""
     assert remove_punctuation(" \t\n") == " \t\n"