libextractor-python

GNU libextractor
Log | Files | Refs | README | LICENSE

commit fea270d932e34b392a51cd2a003833e14007029c
parent 0480b747353ecde4c5c462d5bbea06d31e3c6cb3
Author: Nils Gillmann <gillmann@infotropique.org>
Date:   Sat, 16 Jun 2018 14:46:49 +0000

+

Signed-off-by: Nils Gillmann <gillmann@infotropique.org>

Diffstat:
Mlibextractor/extractor.py | 19+++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)

diff --git a/libextractor/extractor.py b/libextractor/extractor.py @@ -33,14 +33,25 @@ file-types. libextractor is a part of the GNU project (http://www.gnu.org/). """ from ctypes import * +from ctypes import CDLL from ctypes.util import find_library +import os + +# Can be useful: +# "DYLD_LIBRARY_PATH" in os.environ # fake cdll import +# loading shared object file try: - # loading shared object file - libextractor = cdll.LoadLibrary(find_library('libextractor.so.3')) -except OSError: - libextractor = cdll.extractor + if os.uname()[0] == 'Linux': + libextractor = CDLL('libextractor.so.3') + elif os.uname()[0] == 'Linux': + libextractor = cdll.LoadLibrary(find_library('libextractor.so.3')) + else: + libextractor = cdll.extractor +except: + raise ImportError("Could not find shared 'libextractor' library.") + __all__ = ['Extractor'] __version__ = "1.7"