<s> def load_shlib ( name , verbose = False ) : <EOL> """<STR_LIT>""" <EOL> import ctypes <EOL> import os <EOL> import sys <EOL> medir = os . path . dirname ( os . path . abspath ( __file__ ) ) <EOL> if verbose : <EOL> print ( "<STR_LIT>" + os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print ( "<STR_LIT>" + os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> print ( "<STR_LIT>" + os . environ . get ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> if sys . platform . startswith ( '<STR_LIT>' ) : <EOL> soname = [ "<STR_LIT>" ] <EOL> prefix = "<STR_LIT>" <EOL> paths = [ '<STR_LIT>' , '<STR_LIT>' , os . path . join ( medir , '<STR_LIT:..>' , '<STR_LIT>' ) ] <EOL> elif sys . platform . startswith ( '<STR_LIT>' ) : <EOL> soname = [ "<STR_LIT>" ] <EOL> prefix = "<STR_LIT>" <EOL> paths = [ '<STR_LIT>' , '<STR_LIT>' , os . path . join ( medir , '<STR_LIT:..>' , '<STR_LIT>' ) ] <EOL> else : <EOL> ctypes . windll . kernel32 . SetDllDirectoryA ( os . path . join ( medir ) ) <EOL> soname = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> prefix = '<STR_LIT>' <EOL> paths = [ '<STR_LIT>' , '<STR_LIT:.>' , os . path . join ( medir , '<STR_LIT:..>' , '<STR_LIT>' ) , os . path . join ( medir , '<STR_LIT:..>' , '<STR_LIT>' ) ] <EOL> if verbose : <EOL> print ( "<STR_LIT>" + name ) <EOL> handle = None <EOL> for s in soname : <EOL> for p in paths : <EOL> path = os . path . join ( p , prefix + name + s ) <EOL> try : <EOL> handle = ctypes . cdll . LoadLibrary ( path ) <EOL> break <EOL> except Exception as e : <EOL> if verbose : <EOL> print ( path + "<STR_LIT>" + str ( e ) ) <EOL> return handle </s>
