mirror of
https://github.com/koniu/recoll-webui.git
synced 2025-10-05 02:29:29 +02:00
py: split off and reshuffle recoll_get_config
This commit is contained in:
parent
4fc7195250
commit
7c5667b778
1 changed files with 15 additions and 11 deletions
26
webui.py
26
webui.py
|
@ -88,19 +88,17 @@ def normalise_filename(fn):
|
||||||
out += "_"
|
out += "_"
|
||||||
return out
|
return out
|
||||||
#}}}
|
#}}}
|
||||||
#{{{ get_config
|
#{{{ recoll_get_config
|
||||||
def get_config():
|
def recoll_get_config():
|
||||||
config = {}
|
|
||||||
# find recoll.conf
|
# find recoll.conf
|
||||||
for f in RECOLL_CONFS:
|
for d in RECOLL_CONFS:
|
||||||
f = os.path.expanduser(f)
|
d = os.path.expanduser(d)
|
||||||
f = os.path.expandvars(f)
|
d = os.path.expandvars(d)
|
||||||
f += '/recoll.conf'
|
if os.path.isdir(d):
|
||||||
if os.path.isfile(f):
|
confdir = d
|
||||||
path = f
|
|
||||||
break
|
break
|
||||||
# read recoll.conf
|
# read recoll.conf
|
||||||
rc_ini_str = '[main]\n' + open(path, 'r').read()
|
rc_ini_str = '[main]\n' + open(confdir + '/recoll.conf', 'r').read()
|
||||||
rc_ini_fp = StringIO.StringIO(rc_ini_str)
|
rc_ini_fp = StringIO.StringIO(rc_ini_str)
|
||||||
rc_ini = ConfigParser.RawConfigParser()
|
rc_ini = ConfigParser.RawConfigParser()
|
||||||
rc_ini.readfp(rc_ini_fp)
|
rc_ini.readfp(rc_ini_fp)
|
||||||
|
@ -110,7 +108,13 @@ def get_config():
|
||||||
rc[s] = {}
|
rc[s] = {}
|
||||||
for k, v in rc_ini.items(s):
|
for k, v in rc_ini.items(s):
|
||||||
rc[s][k] = v
|
rc[s][k] = v
|
||||||
|
return confdir, rc
|
||||||
|
#}}}
|
||||||
|
#{{{ get_config
|
||||||
|
def get_config():
|
||||||
|
config = {}
|
||||||
# get useful things from recoll.conf
|
# get useful things from recoll.conf
|
||||||
|
config['confdir'], rc = recoll_get_config()
|
||||||
config['dirs'] = shlex.split(rc['main']['topdirs'])
|
config['dirs'] = shlex.split(rc['main']['topdirs'])
|
||||||
# get config from cookies or defaults
|
# get config from cookies or defaults
|
||||||
for k, v in DEFAULTS.items():
|
for k, v in DEFAULTS.items():
|
||||||
|
@ -163,7 +167,7 @@ def recoll_search(q):
|
||||||
config = get_config()
|
config = get_config()
|
||||||
tstart = datetime.datetime.now()
|
tstart = datetime.datetime.now()
|
||||||
results = []
|
results = []
|
||||||
db = recoll.connect()
|
db = recoll.connect(config['confdir'])
|
||||||
db.setAbstractParams(config['maxchars'], config['context'])
|
db.setAbstractParams(config['maxchars'], config['context'])
|
||||||
query = db.query()
|
query = db.query()
|
||||||
query.sortby(q['sort'], q['ascending'])
|
query.sortby(q['sort'], q['ascending'])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue