Commit a7fca255 authored by Jean-Francois Dockes's avatar Jean-Francois Dockes
Browse files

uprcl: make sure that the special >> entries stay at the top of lists.

parent f06af0c5
......@@ -426,12 +426,6 @@ class Folders(object):
# (diridx,self._dirvec[diridx]))
entries = []
# Add "Browse subtree by tags" entry
if pid != self._idprefix and self._enabletags:
id = pid + '$tagview.0'
entries.append(rcldirentry(id, pid, ">> Tag View"))
# The basename call is just for diridx==0 (topdirs). Remove it if
# this proves a performance issue
for nm,ids in self._dirvec[diridx].items():
......@@ -467,11 +461,13 @@ class Folders(object):
if e:
entries.append(e)
if PY3:
return sorted(entries, key=cmpentries)
else:
return sorted(entries, cmp=cmpentries)
entries.sort(key=cmpentries)
# Add "Browse subtree by tags" entry
if pid != self._idprefix and self._enabletags:
id = pid + '$tagview.0'
entries.insert(0, rcldirentry(id, pid, ">> Tag View"))
return entries
# Return path for objid, which has to be a container.This is good old
# pwd... It is called from the search module for generating a 'dir:'
......
......@@ -126,7 +126,4 @@ class Playlists(object):
if e:
entries.append(e)
if PY3:
return sorted(entries, key=cmpentries)
else:
return sorted(entries, cmp=cmpentries)
return sorted(entries, key=cmpentries)
......@@ -265,11 +265,8 @@ def search(foldersobj, rclconfdir, objid, upnps, idprefix, httphp, pathprefix):
break
uplog("Search retrieved %d docs" % (len(entries),))
if PY3:
return sorted(entries, key=uprclutils.cmpentries)
else:
return sorted(entries, cmp=uprclutils.cmpentries)
entries.sort(key=uprclutils.cmpentries)
return entries
if __name__ == '__main__':
s = '(upnp:artist derivedFrom "abc\\"def\\g") or (dc:title:xxx) '
......
......@@ -113,10 +113,7 @@ class Tagged(object):
entries = [rcldoctoentry(pid + '$i' + str(r[0]),
pid, self._httphp, self._pprefix,
rcldocs[r[0]]) for r in c]
if PY3:
return sorted(entries, key=cmpentries)
else:
return sorted(entries, cmp=cmpentries)
return sorted(entries, key=cmpentries)
# Return a list of trackids as selected by the current
......@@ -349,10 +346,7 @@ class Tagged(object):
entries += [rcldoctoentry(pid + '$i' + str(docid),
pid, self._httphp, self._pprefix,
rcldocs[docid]) for docid in docids]
if PY3:
return sorted(entries, key=cmpentries)
else:
return sorted(entries, cmp=cmpentries)
return sorted(entries, key=cmpentries)
# Main browsing routine. Given an objid, translate it into a select
......@@ -453,10 +447,7 @@ class Tagged(object):
entries.append(rcldoctoentry(id, pid, self._httphp,
self._pprefix,
rcldocs[docidx]))
if PY3:
entries = sorted(entries, key=cmpentries)
else:
entries = sorted(entries, cmp=cmpentries)
entries = sorted(entries, key=cmpentries)
else:
# SELECT col.col_id, col.value FROM tracks, col
# WHERE tracks.col_id = col.col_id
......
......@@ -399,10 +399,7 @@ def _cmpentries_func(e1, e2):
uplog("upnp:originalTrackNumber %s %s"% (a1, a2))
return 0
if PY3:
cmpentries=functools.cmp_to_key(_cmpentries_func)
else:
cmpentries=_cmpentries_func
cmpentries=functools.cmp_to_key(_cmpentries_func)
# Find first non loopback ip. This is surprisingly
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment