def __new__(cls, library_path=''):
        if library_path == '':
            errs = []
            for path in cls.get_library_paths():
                try:
                    return cls(path)
                except __HOLE__ as e:
                    logger.debug('Could not open VISA library %s: %s', path, str(e))
                    errs.append(str(e))
                except Exception as e:
                    errs.append(str(e))
            else:
                raise OSError('Could not open VISA library:\n' + '\n'.join(errs))

        if (cls, library_path) in cls._registry:
            return cls._registry[(cls, library_path)]

        obj = super(VisaLibraryBase, cls).__new__(cls)

        obj.library_path = library_path

        obj._logging_extra = {'library_path': obj.library_path}

        obj._init()

        # Create instance specific registries.
        #: Error codes on which to issue a warning.
        obj.issue_warning_on = set(errors.default_warnings)
        obj._last_status_in_session = dict()
        obj._ignore_warning_in_session = defaultdict(set)
        obj.handlers = defaultdict(list)

        logger.debug('Created library wrapper for %s', library_path)

        cls._registry[(cls, library_path)] = obj

        return obj
dataset/ETHPy150Open hgrecco/pyvisa/pyvisa/highlevel.py/VisaLibraryBase.__new__