<commit_before>import importlib

import controllers

# Dependency: pyVISA
import visa

class c_VISA(controllers.c_Base):
    """
    VISA Controller
    
    Wraps PyVISA. Requires a VISA driver to be installed on the system.
    
    __Vendors dictionary:
    -KEY is the contents of the first comma-seperated segment of the identification string
    -VALUE is a tuple with the human readable vendor string and a lambda expression to extract the model information from the identification string
    
    TODO: Make the key a RegEx expression to match. The scanner will try to match the first expression and use it to decode the identify
    """
    
    __Vendors = {'Agilent Technologies': ('Agilent', lambda x: x[1]),
                 'TEKTRONIX':            ('Tektronix', lambda x: x[1])
                }
    
    # Dict: ResID -> (VID, PID)
    resources = {}
    # Dict: ResID -> PyVISA Instrument Object
    instruments = {}
    
    #===========================================================================
    # Required API Function Definitions
    #===========================================================================
    
    def open(self):
        """
        Initialize the interface
        
        Use self.logger to log events and errors
        
        Return True if success, False if an error occurred
        """
        
        try:
            # Load the VISA Resource Manager
            self.__rm = visa.ResourceManager()
            self.logger.debug(str(self.__rm))
            
            self.refresh()
            
            return True
            
        except:
            self.__rm = None<commit_msg>Moved visa import into open() to prevent ImportError exceptions<commit_after>import importlib

import controllers

class c_VISA(controllers.c_Base):
    """
    VISA Controller
    
    Wraps PyVISA. Requires a VISA driver to be installed on the system.
    
    __Vendors dictionary:
    -KEY is the contents of the first comma-seperated segment of the identification string
    -VALUE is a tuple with the human readable vendor string and a lambda expression to extract the model information from the identification string
    
    TODO: Make the key a RegEx expression to match. The scanner will try to match the first expression and use it to decode the identify
    """
    
    __Vendors = {'Agilent Technologies': ('Agilent', lambda x: x[1]),
                 'TEKTRONIX':            ('Tektronix', lambda x: x[1])
                }
    
    # Dict: ResID -> (VID, PID)
    resources = {}
    # Dict: ResID -> PyVISA Instrument Object
    instruments = {}
    
    #===========================================================================
    # Required API Function Definitions
    #===========================================================================
    
    def open(self):
        """
        Initialize the interface
        
        Use self.logger to log events and errors
        
        Return True if success, False if an error occurred
        """
        
        try:
            # Dependency: pyVISA
            import visa

            # Load the VISA Resource Manager
            self.__rm = visa.ResourceManager()
            self.logger.debug(str(self.__rm))
            
            self.refresh()
            
            return True
            
        except:
            self.__rm = None
{'fraction_non_alphanumeric': 0.14843287995269072, 'fraction_numerical': 0.0011827321111768185, 'mean_word_length': 2.0894977168949773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3474665', 'n_tokens_mistral': 840, 'n_tokens_neox': 802, 'n_words': 307}