def load_vars(path, vars):
    """Load variables from a pickle file.
    
    Arguments:
    
      * path: the path to the pickle file.
      * vars: a list of variable names.
    
    Returns:
    
      * cache: a dictionary {var_name: var_value}.
    
    """
    with open(path, 'rb') as f:
        # Load the variables from the cache.
        try:
            cache = pickle.load(f)
        except EOFError as e:
            cache={}
            #raise IOError(str(e))
        
        # Check that all requested variables could be loaded successfully
        # from the cache.
        missing_vars = sorted(set(vars) - set(cache.keys()))
        if missing_vars:
            raise ValueError(("The following variables could not be loaded "
                "from the cache: {0:s}").format(
                ', '.join(["'{0:s}'".format(var) for var in missing_vars])))
        additional_vars = sorted(set(cache.keys()) - set(vars))
        for hidden_variable in '_captured_io', '_cell_md5':
            try:
                additional_vars.remove(hidden_variable)
            except __HOLE__:
                pass
        if additional_vars:
            raise ValueError("The following variables were present in the cache, "
                    "but removed from the storage request: {0:s}".format(
                ', '.join(["'{0:s}'".format(var) for var in additional_vars])))
        
        return cache
dataset/ETHPy150Open rossant/ipycache/ipycache.py/load_vars