Windows: small fixes for rclmpdf.py to work with alivate poppler

This commit is contained in:
Jean-Francois Dockes
2015-10-01 16:36:29 +02:00
parent 376e5485dc
commit a411d4c964
4 changed files with 35 additions and 9 deletions
+23 -9
View File
@@ -1,10 +1,12 @@
#!/usr/bin/env python
from __future__ import print_function
import locale
import re
import os
import sys
import base64
import platform
class ConfSimple:
"""A ConfSimple class reads a recoll configuration file, which is a typical
@@ -143,14 +145,23 @@ class RclDynConf:
class RclConfig:
def __init__(self, argcnf = None):
platsys = platform.system()
# Find configuration directory
if argcnf is not None:
self.confdir = os.path.abspath(argcnf)
elif "RECOLL_CONFDIR" in os.environ:
self.confdir = os.environ["RECOLL_CONFDIR"]
else:
self.confdir = os.path.expanduser("~/.recoll")
#print("Confdir: [%s]" % self.confdir)
if platsys == "Windows":
if "LOCALAPPDATA" in os.environ:
dir = os.environ["LOCALAPPDATA"]
else:
dir = os.path.expanduser("~")
self.confdir = os.path.join(dir, "Recoll")
else:
self.confdir = os.path.expanduser("~/.recoll")
#print("Confdir: [%s]" % self.confdir, file=sys.stderr)
# Also find datadir. This is trickier because this is set by
# "configure" in the C code. We can only do our best. Have to
# choose a preference order. Use RECOLL_DATADIR if the order is wrong
@@ -158,14 +169,17 @@ class RclConfig:
if "RECOLL_DATADIR" in os.environ:
self.datadir = os.environ["RECOLL_DATADIR"]
else:
dirs = ("/opt/local", "/usr", "/usr/local")
for dir in dirs:
dd = os.path.join(dir, "share/recoll")
if os.path.exists(dd):
self.datadir = dd
if platsys == "Windows":
self.datadir = os.path.join(os.path.dirname(sys.argv[0]), "..")
else:
dirs = ("/opt/local", "/usr", "/usr/local")
for dir in dirs:
dd = os.path.join(dir, "share/recoll")
if os.path.exists(dd):
self.datadir = dd
if self.datadir is None:
self.datadir = "/usr/share/recoll"
#print("Datadir: [%s]" % self.datadir)
#print("Datadir: [%s]" % self.datadir, file=sys.stderr)
self.cdirs = []
# Additional config directory, values override user ones
@@ -176,7 +190,7 @@ class RclConfig:
if "RECOLL_CONFMID" in os.environ:
self.cdirs.append(os.environ["RECOLL_CONFMID"])
self.cdirs.append(os.path.join(self.datadir, "examples"))
#print("Config dirs: %s" % self.cdirs, file=sys.stderr)
self.config = ConfStack("recoll.conf", self.cdirs, "tree")
self.keydir = ''