def _generic_handler(line,num_for_key=None):
    """
    Handle a gromacs itp-style line.   
    
    num_for_key: number of fields to use for the key, starting from the first 
                 field.  This means an atom field (1,) or bond field (1,2), or
                 angle field (1,2,3), etc. can use the same parsing function
    """
    
    # Get rid of everything after comment
    line = line.split(";")[0].strip()
    
    # If line only has comments or is blank, return nothing
    if line == "":
        return None
    else:
        
        # If no num_for_key is specified, use the whole line (less the comment)
        # as a key
        if num_for_key is None:
            key = line
            
        # If num_for_key is specified, grab fields 0-num_for_key and use as key
        else:
            key = tuple(line.split()[0:num_for_key])
        value = line
        
        return key, value