From 74cb60908a0521500d09828caa9a94615736f805 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=B6rg=20Lehmann?= Date: Sun, 15 May 2011 12:04:54 +0000 Subject: [PATCH] silently disable pykpathsea locator if extension module is not available git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@3103 069f4177-920e-0410-937b-c2a4a81bcd90 --- pyx/filelocator.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyx/filelocator.py b/pyx/filelocator.py index b4c77c7c..292411df 100644 --- a/pyx/filelocator.py +++ b/pyx/filelocator.py @@ -26,6 +26,12 @@ import os, cStringIO, warnings, pkgutil import config, pycompat +try: + import pykpathsea + has_pykpathsea = True +except ImportError: + has_pykpathsea = False + # Locators implement an open method which returns a list of functions # by searching for a file according to a specific rule. Each of the functions @@ -149,7 +155,8 @@ class pykpathsea: """locate files by pykpathsea (a C extension module wrapping libkpathsea)""" def openers(self, filename, names, extensions, mode): - import pykpathsea + if not has_pykpathsea: + return [] for name in names: full_filename = pykpathsea.find_file(filename, name) if full_filename: -- 2.11.4.GIT