|
a/src/mediaserver/cdplugins/uprcl/uprcluntagged.py |
|
b/src/mediaserver/cdplugins/uprcl/uprcluntagged.py |
|
... |
|
... |
17 |
import os
|
17 |
import os
|
18 |
import shlex
|
18 |
import shlex
|
19 |
import urllib
|
19 |
import urllib
|
20 |
import sys
|
20 |
import sys
|
21 |
|
21 |
|
22 |
from uprclutils import *
|
22 |
from uprclutils import uplog, rcldoctoentry, rcldirentry, cmpentries
|
23 |
|
23 |
|
24 |
from recoll import recoll
|
|
|
25 |
from recoll import rclconfig
|
|
|
26 |
|
|
|
27 |
g_myprefix = '0$uprcl$untagged'
|
24 |
untg_prefix = '0$uprcl$untagged'
|
28 |
|
|
|
29 |
|
25 |
|
30 |
def recoll2untagged(docs):
|
26 |
def recoll2untagged(docs):
|
31 |
global g_utidx, g_rcldocs
|
27 |
global g_utidx, g_rcldocs
|
32 |
g_rcldocs = docs
|
28 |
g_rcldocs = docs
|
33 |
g_utidx = [-1]
|
29 |
g_utidx = [-1]
|
|
... |
|
... |
45 |
tt = doc.title
|
41 |
tt = doc.title
|
46 |
if not tt:
|
42 |
if not tt:
|
47 |
g_utidx.append(docidx)
|
43 |
g_utidx.append(docidx)
|
48 |
|
44 |
|
49 |
def _objidtoidx(pid):
|
45 |
def _objidtoidx(pid):
|
50 |
if not pid.startswith(g_myprefix):
|
46 |
if not pid.startswith(untg_prefix):
|
51 |
raise Exception("untagged.browse: bad pid %s" % pid)
|
47 |
raise Exception("untagged.browse: bad pid %s" % pid)
|
52 |
|
48 |
|
53 |
if len(g_rcldocs) == 0:
|
49 |
if len(g_rcldocs) == 0:
|
54 |
raise Exception("untagged:browse: no docs")
|
50 |
raise Exception("untagged:browse: no docs")
|
55 |
|
51 |
|
56 |
idx = pid[len(g_myprefix):]
|
52 |
idx = pid[len(untg_prefix):]
|
57 |
if not idx:
|
53 |
if not idx:
|
58 |
idx = 0
|
54 |
idx = 0
|
59 |
else:
|
55 |
else:
|
60 |
if idx[1] != 'u':
|
56 |
if idx[1] != 'u':
|
61 |
raise Exception("untagged:browse: called on bad objid %s" % pid)
|
57 |
raise Exception("untagged:browse: called on bad objid %s" % pid)
|
|
... |
|
... |
80 |
entries = []
|
76 |
entries = []
|
81 |
if idx == 0:
|
77 |
if idx == 0:
|
82 |
# Browsing root
|
78 |
# Browsing root
|
83 |
for i in range(len(g_utidx))[1:]:
|
79 |
for i in range(len(g_utidx))[1:]:
|
84 |
doc = g_rcldocs[g_utidx[i]]
|
80 |
doc = g_rcldocs[g_utidx[i]]
|
85 |
id = g_myprefix + '$u' + str(i)
|
81 |
id = untg_prefix + '$u' + str(i)
|
86 |
e = rcldoctoentry(id, pid, httphp, pathprefix, doc)
|
82 |
e = rcldoctoentry(id, pid, httphp, pathprefix, doc)
|
87 |
if e:
|
83 |
if e:
|
88 |
entries.append(e)
|
84 |
entries.append(e)
|
89 |
else:
|
85 |
else:
|
90 |
# Non root: only items in there. flag needs to be 'meta'
|
86 |
# Non root: only items in there. flag needs to be 'meta'
|
91 |
doc = g_rcldocs[thisdocidx]
|
87 |
doc = g_rcldocs[thisdocidx]
|
92 |
id = g_myprefix + '$u' + str(idx)
|
88 |
id = untg_prefix + '$u' + str(idx)
|
93 |
e = rcldoctoentry(id, pid, httphp, pathprefix, doc)
|
89 |
e = rcldoctoentry(id, pid, httphp, pathprefix, doc)
|
94 |
if e:
|
90 |
if e:
|
95 |
entries.append(e)
|
91 |
entries.append(e)
|
96 |
|
92 |
|
97 |
return sorted(entries, cmp=cmpentries)
|
93 |
return sorted(entries, cmp=cmpentries)
|