本文整理汇总了Python中quodlibet.util.human_sort_key函数的典型用法代码示例。如果您正苦于以下问题:Python human_sort_key函数的具体用法?Python human_sort_key怎么用?Python human_sort_key使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了human_sort_key函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cmp_rows
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)))
示例2: sort_key
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")))
示例3: __human_sort_key
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]
示例4: sort
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)))
示例5: __human_sort_key
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
示例6: __init__
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
示例7: genre
def genre(self):
return util.human_sort_key(self.get("genre").split("\n")[0])
示例8: peoplesort
def peoplesort(self):
return util.human_sort_key(self.get("~peoplesort").split("\n")[0])
示例9: test_white
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)
示例10: test_false
def test_false(self):
# album browser needs that to sort albums without artist/title
# to the bottom
self.failIf(util.human_sort_key(""))
示例11: smaller
def smaller(self, x, y):
return util.human_sort_key(x) < util.human_sort_key(y)
示例12: _get_key
def _get_key(song, tag):
if tag.startswith("~#") and "~" not in tag[2:]:
return song(tag)
return human_sort_key(song(tag))
示例13: equal
def equal(self, x, y):
return util.human_sort_key(x) == util.human_sort_key(y)