Return a boolean indicating whether a library is found.
771293
def has_library(compiler, libname):
    """"""
    with tempfile.NamedTemporaryFile("w", suffix=".cpp") as srcfile:
        srcfile.write("int main (int argc, char **argv) { return 0; }")
        srcfile.flush()
        outfn = srcfile.name + ".so"
        try:
            compiler.link_executable(
                [srcfile.name],
                outfn,
                libraries=[libname],
            )
        except setuptools.distutils.errors.LinkError:
            return False
        if not os.path.exists(outfn):
            return False
        os.remove(outfn)
    return True
510696
def contains_info(self, key, value):
        
        if self.library is None:
            return 0

        load = self.library.load_card
        matches = 0
        for code in self.cards:
            card = load(code)
            if card.get_info(key) == value:
                matches += 1
        return matches
631072
def get_library(self, library):
        
        if library in self._library_cache:
            return self._library_cache[library]

        try:
            error = None
            lib = ArcticLibraryBinding(self, library)
            lib_type = lib.get_library_type()
        except (OperationFailure, AutoReconnect) as e:
            error = e

        if error:
            raise LibraryNotFoundException("Library %s was not correctly initialized in %s.\nReason: %r)" %
                                           (library, self, error))
        elif not lib_type:
            raise LibraryNotFoundException("Library %s was not correctly initialized in %s." %
                                           (library, self))
        elif lib_type not in LIBRARY_TYPES:
            raise LibraryNotFoundException("Couldn't load LibraryType '%s' for '%s' (has the class been registered?)" %
                                           (lib_type, library))
        instance = LIBRARY_TYPES[lib_type](lib)
        self._library_cache[library] = instance
        # The library official name may be different from 'library': e.g. 'library' vs 'user.library'
        self._library_cache[lib.get_name()] = instance
        return self._library_cache[library]
924291
def check_aubio():
    ""
    try:
        import aubio
    except ImportError:
        warnings.warn('Aubio librairy is not available', ImportWarning,
                      stacklevel=2)
        _WITH_AUBIO = False
    else:
        _WITH_AUBIO = True
        del aubio

    return _WITH_AUBIO
469773
def include_library(libname):
    """"""
    # For configuration phase we need to have exclude / include lists None
    # so these checking is skipped and library gets included.
    if exclude_list:
        if exclude_list.search(libname) and not include_list.search(libname):
            # Library is excluded and is not overriden by include list.
            # It should be then excluded.
            return False
        else:
            # Include library
            return True
    else:
        # By default include library.
        return True
298412
@Override
    public boolean libraryExists(String libraryName)
    {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        String localePrefix = getLocalePrefixForLocateResource(facesContext);
        final List<String> contracts = facesContext.getResourceLibraryContracts(); 

        String pathToLib = null;
        Boolean libraryFound = null;
        if (libraryName != null && !ResourceValidationUtils.isValidLibraryName(
                libraryName, isAllowSlashesLibraryName()))
        {
            return false;
        }
        
        if (localePrefix != null)
        {
            //Check with locale
            pathToLib = localePrefix + '/' + libraryName;

            libraryFound = getResourceLoaderCache().libraryExists(pathToLib);
            if (libraryFound != null)
            {
                return libraryFound.booleanValue();
            }
        }
        libraryFound = getResourceLoaderCache().libraryExists(libraryName);
        if (libraryFound != null)
        {
            return libraryFound.booleanValue();
        }
        
        if (localePrefix != null)
        {
            if (!contracts.isEmpty())
            {
                for (String contract : contracts)
                {
                    for (ContractResourceLoader loader : getResourceHandlerSupport()
                            .getContractResourceLoaders())
                    {
                        if (loader.libraryExists(pathToLib, contract))
                        {
                            getResourceLoaderCache().confirmLibraryExists(pathToLib);
                            return true;
                        }
                    }
                }
            }
            
            for (ResourceLoader loader : getResourceHandlerSupport()
                    .getResourceLoaders())
            {
                if (loader.libraryExists(pathToLib))
                {
                    getResourceLoaderCache().confirmLibraryExists(pathToLib);
                    return true;
                }
            }            
        }

        //Check without locale
        if (!contracts.isEmpty())
        {
            for (String contract : contracts)
            {
                for (ContractResourceLoader loader : getResourceHandlerSupport()
                        .getContractResourceLoaders())
                {
                    if (loader.libraryExists(libraryName, contract))
                    {
                        getResourceLoaderCache().confirmLibraryExists(libraryName);
                        return true;
                    }
                }
            }
        }

        for (ResourceLoader loader : getResourceHandlerSupport()
                .getResourceLoaders())
        {
            if (loader.libraryExists(libraryName))
            {
                getResourceLoaderCache().confirmLibraryExists(libraryName);
                return true;
            }
        }

        if (localePrefix != null)
        {
            //Check with locale
            getResourceLoaderCache().confirmLibraryNotExists(pathToLib);
        }
        else
        {
            getResourceLoaderCache().confirmLibraryNotExists(libraryName);
        }
        return false;
    }
708814
def check_if_exists(self):
        """"""
        if self.req is None:
            return False
        try:
            self.satisfied_by = pkg_resources.get_distribution(self.req)
        except pkg_resources.DistributionNotFound:
            return False
        except pkg_resources.VersionConflict:
            self.conflicts_with = pkg_resources.get_distribution(self.req.project_name)
        return True
653757
function isLibrary (node) {
  return nodeType(node, exactMatch(nodeTypes.CONTRACTDEFINITION)) && node.attributes.isLibrary === true
}
75060
def find_lib_path():
    
    lib_from_env = os.environ.get('MXNET_LIBRARY_PATH')
    if lib_from_env:
        if os.path.isfile(lib_from_env):
            if not os.path.isabs(lib_from_env):
                logging.warning("MXNET_LIBRARY_PATH should be an absolute path, instead of: %s",
                                lib_from_env)
            else:
                if os.name == 'nt':
                    os.environ['PATH'] = os.environ['PATH'] + ';' + os.path.dirname(lib_from_env)
                return [lib_from_env]
        else:
            logging.warning("MXNET_LIBRARY_PATH '%s' doesn't exist", lib_from_env)

    curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
    api_path = os.path.join(curr_path, '../../lib/')
    cmake_build_path = os.path.join(curr_path, '../../build/')
    dll_path = [curr_path, api_path, cmake_build_path]
    if os.name == 'nt':
        dll_path.append(os.path.join(curr_path, '../../build'))
        vs_configuration = 'Release'
        if platform.architecture()[0] == '64bit':
            dll_path.append(os.path.join(curr_path, '../../build', vs_configuration))
            dll_path.append(os.path.join(curr_path, '../../windows/x64', vs_configuration))
        else:
            dll_path.append(os.path.join(curr_path, '../../build', vs_configuration))
            dll_path.append(os.path.join(curr_path, '../../windows', vs_configuration))
    elif os.name == "posix" and os.environ.get('LD_LIBRARY_PATH', None):
        dll_path[0:0] = [p.strip() for p in os.environ['LD_LIBRARY_PATH'].split(":")]
    if os.name == 'nt':
        os.environ['PATH'] = os.path.dirname(__file__) + ';' + os.environ['PATH']
        dll_path = [os.path.join(p, 'libmxnet.dll') for p in dll_path]
    elif platform.system() == 'Darwin':
        dll_path = [os.path.join(p, 'libmxnet.dylib') for p in dll_path] + \
                   [os.path.join(p, 'libmxnet.so') for p in dll_path]
    else:
        dll_path.append('../../../')
        dll_path = [os.path.join(p, 'libmxnet.so') for p in dll_path]
    lib_path = [p for p in dll_path if os.path.exists(p) and os.path.isfile(p)]
    if len(lib_path) == 0:
        raise RuntimeError('Cannot find the MXNet library.\n' +
                           'List of candidates:\n' + str('\n'.join(dll_path)))
    if os.name == 'nt':
        os.environ['PATH'] = os.environ['PATH'] + ';' + os.path.dirname(lib_path[0])
    return lib_path
371449
def _get_library_os_path_from_library_dict_tree(self, library_path, library_name):
        """"""
        if library_path is None or library_name is None:
            return None
        path_list = library_path.split(os.sep)
        target_lib_dict = self.libraries
        # go down the path to the correct library
        for path_element in path_list:
            if path_element not in target_lib_dict:  # Library cannot be found
                target_lib_dict = None
                break
            target_lib_dict = target_lib_dict[path_element]
        return None if target_lib_dict is None or library_name not in target_lib_dict else target_lib_dict[library_name]
1281589
def is_current(self, paths=None):
        """'"""
        version = self.get_version(paths)
        if version is None:
            return False
        return self.version_ok(version)
948574
def get_library(lookup=True, key='exp_id'):
    ''' '''
    library = None
    response = requests.get(EXPFACTORY_LIBRARY)
    if response.status_code == 200:
        library = response.json()
        if lookup is True:
            return make_lookup(library,key=key)
    return library
1152665
def _library_check(self):
        

        try:
            output = yield from gns3server.utils.asyncio.subprocess_check_output("ldd", self._path)
        except (FileNotFoundError, subprocess.SubprocessError) as e:
            log.warn("Could not determine the shared library dependencies for {}: {}".format(self._path, e))
            return

        p = re.compile("([\.\w]+)\s=>\s+not found")
        missing_libs = p.findall(output)
        if missing_libs:
            raise IOUError("The following shared library dependencies cannot be found for IOU image {}: {}".format(self._path,
                                                                                                                   ", ".join(missing_libs)))
301784
def load_library(self,libname):
        """"""
        paths = self.getpaths(libname)

        for path in paths:
            if os.path.exists(path):
                return self.load(path)

        raise ImportError("%s not found." % libname)
107891
def isbinary(*args):
    """"""
    return all(map(lambda c: isnumber(c) or isbool(c), args))
1263679
def get_library_instance(self, library_path, library_name):
        """"""
        if self.is_library_in_libraries(library_path, library_name):
            from rafcon.core.states.library_state import LibraryState
            return LibraryState(library_path, library_name, "0.1")
        else:
            logger.warning("Library manager will not create a library instance which is not in the mounted libraries.")
25668
def check_package_exists(package, lib_dir):
    
    try:
        req = pkg_resources.Requirement.parse(package)
    except ValueError:
        # This is a zip file
        req = pkg_resources.Requirement.parse(urlparse(package).fragment)

    # Check packages from lib dir
    if lib_dir is not None:
        if any(dist in req for dist in
               pkg_resources.find_distributions(lib_dir)):
            return True

    # Check packages from global + virtual environment
    # pylint: disable=not-an-iterable
    return any(dist in req for dist in pkg_resources.working_set)