Example #1
0
        def cmp_rows(model, i1, i2, data):
            t1, t2 = model[i1][0], model[i2][0]
            pos1 = _ORDERING.get(t1, 0)
            pos2 = _ORDERING.get(t2, 0)
            if pos1 or pos2:
                return cmp(pos1, pos2)

            if not isinstance(t1, AlbumNode):
                return cmp(util.human_sort_key(t1), util.human_sort_key(t2))

            a1, a2 = t1.album, t2.album
            return (cmpa(a1.peoplesort, a2.peoplesort)
                    or cmpa(a1.date, a2.date) or cmpa(a1.sort, a2.sort)
                    or cmp(a1.key, a2.key))
Example #2
0
        def cmp_rows(model, i1, i2, data):
            t1, t2 = model[i1][0], model[i2][0]
            pos1 = _ORDERING.get(t1, 0)
            pos2 = _ORDERING.get(t2, 0)
            if pos1 or pos2:
                return cmp(pos1, pos2)

            if not isinstance(t1, AlbumNode):
                return cmp(util.human_sort_key(t1), util.human_sort_key(t2))

            a1, a2 = t1.album, t2.album
            return (cmp(a1.peoplesort and a1.peoplesort[0],
                        a2.peoplesort and a2.peoplesort[0]) or
                    cmp(a1.date or "ZZZZ", a2.date or "ZZZZ") or
                    cmp((a1.sort, a1.key), (a2.sort, a2.key)))
Example #3
0
def sort_key(song):
    """Sort by path so untagged albums have a good start order. Also
    take into account the directory in case it's split in different folders
    by medium.
    """

    return util.human_sort_key(fsn2text(song("~filename")))
Example #4
0
def sort_key(song):
    """Sort by path so untagged albums have a good start order. Also
    take into account the directory in case it's split in different folders
    by medium.
    """

    return util.human_sort_key(path.fsdecode(song("~filename")))
Example #5
0
 def __human_sort_key(self, text, reg=re.compile('<.*?>')):
     try:
         return self.__sort_cache[text]
     except KeyError:
         # remove the markup so it doesn't affect the sort order
         if self.pattern.has_markup:
             text = reg.sub("", text)
         self.__sort_cache[text] = util.human_sort_key(text)
         return self.__sort_cache[text]
Example #6
0
 def __human_sort_key(self, text, reg=re.compile('<.*?>')):
     try:
         return self.__sort_cache[text]
     except KeyError:
         # remove the markup so it doesn't affect the sort order
         if self.config.has_markup:
             text = reg.sub("", text)
         self.__sort_cache[text] = util.human_sort_key(text)
         return self.__sort_cache[text]
Example #7
0
        def sort(model, i1, i2, data):
            t1, t2 = model[i1][0], model[i2][0]
            if t1 is None or t2 is None:
                # FIXME: why?
                return 0

            # FIXME: order this deterministically
            if t1 is MultiNode or t1 is UnknownNode or \
                    t2 is MultiNode or t2 is UnknownNode:
                return -cmp(t1, t2)

            if not isinstance(t1, Album):
                return cmp(util.human_sort_key(t1), util.human_sort_key(t2))

            a1, a2 = t1, t2
            return (cmp(a1.peoplesort and a1.peoplesort[0],
                        a2.peoplesort and a2.peoplesort[0]) or
                        cmp(a1.date or "ZZZZ", a2.date or "ZZZZ") or
                        cmp((a1.sort, a1.key), (a2.sort, a2.key)))
Example #8
0
 def __human_sort_key(self, text, reg=re.compile('<.*?>')):
     try:
         return self.__sort_cache[text], text
     except KeyError:
         # remove the markup so it doesn't affect the sort order
         if self.config.has_markup:
             text_stripped = reg.sub("", text)
         else:
             text_stripped = text
         self.__sort_cache[text] = util.human_sort_key(text_stripped)
         return self.__sort_cache[text], text
Example #9
0
 def genre(self):
     return util.human_sort_key(self.get("genre").split("\n")[0])
Example #10
0
 def peoplesort(self):
     return util.human_sort_key(self.get("~peoplesort").split("\n")[0])
Example #11
0
 def test_white(self):
     self.failUnlessEqual(util.human_sort_key(u"  3foo    bar6 42.8"),
                          util.human_sort_key(u"3 foo bar6  42.8  "))
     self.failUnlessEqual(64.0 in util.human_sort_key(u"64. 8"), True)
Example #12
0
 def test_false(self):
     # album browser needs that to sort albums without artist/title
     # to the bottom
     self.failIf(util.human_sort_key(""))
Example #13
0
 def equal(self, x, y):
     return util.human_sort_key(x) == util.human_sort_key(y)
Example #14
0
 def smaller(self, x, y):
     return util.human_sort_key(x) < util.human_sort_key(y)
 def genre(self):
     return util.human_sort_key(self.get("genre").split("\n")[0])
Example #16
0
 def equal(self, x, y):
     return util.human_sort_key(x) == util.human_sort_key(y)
Example #17
0
 def _get_key(song, tag):
     if tag.startswith("~#") and "~" not in tag[2:]:
         return song(tag)
     return human_sort_key(song(tag))
 def peoplesort(self):
     return util.human_sort_key(self.get("~peoplesort").split("\n")[0])
Example #19
0
 def test_white(self):
     self.failUnlessEqual(
         util.human_sort_key(u"  3foo    bar6 42.8"),
         util.human_sort_key(u"3 foo bar6  42.8  "))
     self.failUnlessEqual(64.0 in util.human_sort_key(u"64. 8"), True)
Example #20
0
 def test_false(self):
     # album browser needs that to sort albums without artist/title
     # to the bottom
     self.failIf(util.human_sort_key(""))
Example #21
0
 def smaller(self, x, y):
     return util.human_sort_key(x) < util.human_sort_key(y)
Example #22
0
 def __init__(self, song):
     super(Album, self).__init__()
     self.songs = set()
     #albumsort is part of the album_key, so every song has the same
     self.sort = util.human_sort_key(song("albumsort"))
     self.key = song.album_key
 def _get_key(song, tag):
     if tag.startswith("~#") and "~" not in tag[2:]:
         return song(tag)
     return human_sort_key(song(tag))
 def __init__(self, song):
     super(Album, self).__init__()
     self.songs = set()
     # albumsort is part of the album_key, so every song has the same
     self.sort = util.human_sort_key(song("albumsort"))
     self.key = song.album_key