Iterate across the expanded library names in the libyajl2-gem and then
 attempt to load the system libraries.  Uses the native dlopen extension
 that ships in this gem.

 @api private
499233
def dlopen_yajl_library
      found = false
      ( expanded_library_names + library_names ).each do |libname|
        begin
          dlopen(libname)
          found = true
          break
        rescue ArgumentError
        end
      end
      raise "cannot find yajl library for platform" unless found
    end
74863
def load_ctypes_library(name):
    

    try:
        return cdll.LoadLibrary(name)
    except OSError:
        name = find_library(name)
        if name is None:
            raise
        return cdll.LoadLibrary(name)
693575
def ffi_open_yajl_library
      found = false
      expanded_library_names.each do |libname|
        begin
          ffi_lib libname
          found = true
        rescue LoadError
        end
      end
      ffi_lib "yajl" unless found
    end
1170842
function extractLibraries (ast, rootFileDir) {
  if (ast.mappings === undefined) return {}
  const useStatement = ast.mappings.filter(function (e) {
    return e.key.value === 'uses'
  })
  if (useStatement[0] === undefined) return {}
  const libraries = useStatement[0].value.mappings.reduce(function (libs, e) {
    const libraryString = fs.readFileSync(path.join(rootFileDir, e.value.value))
    const libraryAst = yap.load(libraryString)
    const libraryJs = {}
    traverse(libraryJs, libraryAst, rootFileDir)
    libs[e.key.value] = libraryJs
    return libs
  }, {})
  const libs = Object.keys(libraries).reduce(function (lib, name) {
    lib[name] = {}
    Object.keys(libraries[name]).map(function (skip) {
      Object.keys(libraries[name][skip]).map(function (key) {
        lib[name][key] = libraries[name][skip][key]
      })
    })
    return lib
  }, {})
  return libs
}
1045642
def _LoadNvmlLibrary():
    
    global nvmlLib

    if (nvmlLib is None):
        # lock to ensure only one caller loads the library
        libLoadLock.acquire()

        try:
            # ensure the library still isn't loaded
            if (nvmlLib is None):
                try:
                    if (sys.platform[:3] == "win"):
                        searchPaths = [
                            os.path.join(os.getenv("ProgramFiles", r"C:\Program Files"), r"NVIDIA Corporation\NVSMI\nvml.dll"),
                            os.path.join(os.getenv("WinDir", r"C:\Windows"), r"System32\nvml.dll"),
                        ]
                        nvmlPath = next((x for x in searchPaths if os.path.isfile(x)), None)
                        if (nvmlPath == None):
                            _nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
                        else:
                            # cdecl calling convention
                            nvmlLib = CDLL(nvmlPath)
                    else:
                        # assume linux
                        nvmlLib = CDLL("libnvidia-ml.so.1")
                except OSError as ose:
                    _nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
                if (nvmlLib == None):
                    _nvmlCheckReturn(NVML_ERROR_LIBRARY_NOT_FOUND)
        finally:
            # lock is always freed
            libLoadLock.release()
733489
public static String libName() throws UnsupportedOperationException {
        String os = System.getProperty("os.name").toLowerCase();
        if (os.startsWith("windows")) {
            return libNameBare()+".dll";

        } else if (os.startsWith("mac os x")) {
            //	    return libNameBare()+".dylib";
            return libNameBare()+".jnilib";

        } else {
            return "lib"+libNameBare()+".so";
        }  
    }
686524
def load_library_handle(libname, path):
    """"""

    if path is None or path in ['None', 'none']:
        # Either could not find a library via ctypes or
        # user-configuration-file, or we could not find it in any of the
        # default locations, or possibly the user intentionally does not want
        # one of the libraries to load.
        return None

    try:
        if os.name == "nt":
            opj_lib = ctypes.windll.LoadLibrary(path)
        else:
            opj_lib = ctypes.CDLL(path)
    except (TypeError, OSError):
        msg = 'The {libname} library at {path} could not be loaded.'
        msg = msg.format(path=path, libname=libname)
        warnings.warn(msg, UserWarning)
        opj_lib = None

    return opj_lib
177132
def find_static_library(library_name, library_path):
    """"""

    variants = ["lib{0}.a", "{0}.a", "{0}.lib", "lib{0}.lib"]
    if is_unix_like():
        extra_libdirs = ["/usr/local/lib64", "/usr/local/lib",
                "/usr/lib64", "/usr/lib", "/lib64", "/lib"]
    else:
        extra_libdirs = []

    for path in extra_libdirs:
        if path not in library_path and os.path.isdir(path):
            library_path.append(path)

    for path in library_path:
        for variant in variants:
            full_path = os.path.join(path, variant.format(library_name))
            if os.path.isfile(full_path):
                return full_path
1303311
def main():
    
    windows_libraries = list(pylink.Library.find_library_windows())
    latest_library = None
    for lib in windows_libraries:
        if os.path.dirname(lib).endswith('JLinkARM'):
            # Always use the one pointed to by the 'JLinkARM' directory.
            latest_library = lib
            break
        elif latest_library is None:
            latest_library = lib
        elif os.path.dirname(lib) > os.path.dirname(latest_library):
            latest_library = lib

    if latest_library is None:
        raise OSError('No J-Link library found.')

    library = pylink.Library(latest_library)
    jlink = pylink.JLink(lib=library)

    print('Found version: %s' % jlink.version)

    for emu in jlink.connected_emulators():
        jlink.disable_dialog_boxes()
        jlink.open(serial_no=emu.SerialNumber)
        jlink.sync_firmware()
        print('Updated emulator with serial number %s' % emu.SerialNumber)

    return None
950070
def load():
    
    if 'Windows' == platform.system():
        # Possible scenarios here
        #   1. Run from source, DLLs are in pylibdmtx directory
        #       cdll.LoadLibrary() imports DLLs in repo root directory
        #   2. Wheel install into CPython installation
        #       cdll.LoadLibrary() imports DLLs in package directory
        #   3. Wheel install into virtualenv
        #       cdll.LoadLibrary() imports DLLs in package directory
        #   4. Frozen
        #       cdll.LoadLibrary() imports DLLs alongside executable

        fname = _windows_fname()
        try:
            libdmtx = cdll.LoadLibrary(fname)
        except OSError:
            libdmtx = cdll.LoadLibrary(
                str(Path(__file__).parent.joinpath(fname))
            )
    else:
        # Assume a shared library on the path
        path = find_library('dmtx')
        if not path:
            raise ImportError('Unable to find dmtx shared library')
        libdmtx = cdll.LoadLibrary(path)

    return libdmtx
647068
def pickle_load(name, extension='.pkl'):
    
    filename = name + extension
    infile = open(filename, 'rb')
    data = pickle.load(infile)
    infile.close()
    return data
735030
function() {
    var lib, name, names, _i, _len;
    lib = arguments[0], names = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
    for (_i = 0, _len = names.length; _i < _len; _i++) {
      name = names[_i];
      if (lib[name] == null) {
        return;
      }
      if (this[name] == null) {
        this[name] = {};
      }
      if (!isObject(this[name])) {
        return;
      }
      mixin(this[name], lib[name]);
    }
    return this;
  }
1313076
def _load_library(self):
        
        path = self._library_path()
        logger.info("Loading library from path {}".format(path))
        library_dir = os.path.dirname(path)
        if platform.system() == 'Windows':
            import win32api
            olddir = os.getcwd()
            os.chdir(library_dir)
            win32api.SetDllDirectory('.')

        result = cdll.LoadLibrary(path)

        if platform.system() == 'Windows':
            os.chdir(olddir)

        return result
764373
def load(self,path):
        """"""
        try:
            # Darwin requires dlopen to be called with mode RTLD_GLOBAL instead
            # of the default RTLD_LOCAL.  Without this, you end up with
            # libraries not being loadable, resulting in "Symbol not found"
            # errors
            if sys.platform == 'darwin':
                return ctypes.CDLL(path, ctypes.RTLD_GLOBAL)
            else:
                return ctypes.cdll.LoadLibrary(path)
        except OSError,e:
            raise ImportError(e)
567072
def load_library(version):
    
    check_version(version)
    module_name = SUPPORTED_LIBRARIES[version]
    lib = sys.modules.get(module_name)
    if lib is None:
        lib = importlib.import_module(module_name)
    return lib
336378
def _load_lib():
    """"""
    lib_path = find_lib_path()
    if len(lib_path) == 0:
        return None
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
    lib.LGBM_GetLastError.restype = ctypes.c_char_p
    return lib
664767
def parse_gem(init_lib)
      # puts "Processing: #{init_lib}"
      # don't ask
      init_path = init_lib

      init_file = File.read(init_lib)
      current_file = ""

      init_file.each_line do |line|
        if line.strip =~ /^require/
          parser = RubyParser.new
          sexp = parser.parse(line)
          call = sexp[2]

          unless call == :require
            # WEIRD SHIT IS HAPPENING
            current_file += line
            next
          end

          require_type = sexp[3][1][0]
          library = sexp[3][1][1]
          #p library

          if require_type == :str && library.match(@gem_name)
            # fold in
            full_rb_path = File.join([@lib_folder, "#{library}.rb"])
            unless @require_libs.include?(full_rb_path)
              file_index = @require_libs.index(init_lib)
              insert_index = file_index
              @require_libs.insert insert_index, full_rb_path
              parse_gem(full_rb_path)
            end
          else
            current_file += "# FIXME: #require is not supported in RubyMotion\n"
            current_file += "# #{line}"
            next
          end
          # comment it out
          current_file += "# #{line}"
          next
        elsif line.strip =~ /^autoload/
          # same as require
          parser = RubyParser.new
          sexp = parser.parse(line)
          call = sexp[2]

          unless call == :autoload
            # WEIRD SHIT IS HAPPENING
            current_file += line
            next
          end

          require_type = sexp[3][2][0]
          library = sexp[3][2][1]

          full_rb_path = File.join([@lib_folder, "#{library}.rb"])
          unless @require_libs.include?(full_rb_path)
            file_index = @require_libs.index(init_lib)
            insert_index = file_index
            @require_libs.insert insert_index, full_rb_path
            parse_gem(full_rb_path)
          end
          # comment it out
          current_file += "# #{line}"
          next

        
        elsif line.strip =~ /^eval/
            # reprint as a block
            # parser = RubyParser.new
            # sexp = parser.parse(line)
            # code_str = sexp[3][1][1]
            # new_eval = "eval do\n  #{code_str}\nend\n"
            # current_file += "#{new_eval}"
            # next

            # produce a fixme

            current_file += "# FIXME: Cannot eval strings in RubyMotion. \n"
            current_file += "# Rewrite to use a block.. inbuilt hack will run \n"
            current_file += "# Change this: \n"
            current_file += "# eval %Q{ \n" 
            current_file += '# def #{c}(string = nil) ' + "\n"
            current_file += "# To this \n"
            current_file += "# eval do \n"
            current_file += "# define_method(c) do |string| \n"
            current_file += "#{line}"
            next
        elsif line.strip =~ /^binding/
            current_file += "# FIXME: binding is not supported in RubyMotion.\n"
            current_file += "#{line}"
            next
        end

        # dont intefere
        current_file += line
      end

      # replace file
      File.open(init_lib, 'w') {|f| f.write(current_file) } #unless TEST_MODE

    end