#NEWLINE# def __new__( cls , library_path = '' ) : #NEWLINE# #INDENT# if ( library_path == '' ) : #NEWLINE# #INDENT# errs = [ ] #NEWLINE# for path in cls . get_library_paths ( ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# return cls ( path ) #NEWLINE# #UNINDENT# except OSError as e : #NEWLINE# #INDENT# logger . debug ( 'Could not open VISA library %s: %s' , path , str ( e ) ) #NEWLINE# errs . append ( str ( e ) ) #NEWLINE# #UNINDENT# except Exception as e : #NEWLINE# #INDENT# errs . append ( str ( e ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# raise OSError ( ( 'Could not open VISA library:\n' + '\n' . join ( errs ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# if ( ( cls , library_path ) in cls . _registry ) : #NEWLINE# #INDENT# return cls . _registry [ ( cls , library_path ) ] #NEWLINE# #UNINDENT# obj = super ( VisaLibraryBase , cls ) . __new__ ( cls ) #NEWLINE# obj . library_path = library_path #NEWLINE# obj . _logging_extra = { #NEWLINE# #INDENT# 'library_path' : obj . library_path , #NEWLINE# #UNINDENT# } #NEWLINE# obj . _init ( ) #NEWLINE# obj . issue_warning_on = set ( errors . default_warnings ) #NEWLINE# obj . _last_status_in_session = dict ( ) #NEWLINE# obj . _ignore_warning_in_session = defaultdict ( set ) #NEWLINE# obj . handlers = defaultdict ( list ) #NEWLINE# logger . debug ( 'Created library wrapper for %s' , library_path ) #NEWLINE# cls . _registry [ ( cls , library_path ) ] = obj #NEWLINE# return cls