import inspect


def extract_fields(obj, attr_key):
    """Return the fields of an object
        
    Keyword arguments:
    obj -- Object to be inspected
    attr_key -- Key to look for in list from inspection
        
    Inspects object (a message) to get a list of the attributes
    Go through the list to find the dictionary with provided key
    Return the dictionary (key: fieldname, value: fieldtype) 
    """
    # using inspect.getmembers() because messages use slots
    # attrs is a list
    attrs = inspect.getmembers(obj)
    fields = dict()
    for key, value in attrs:
        if(key == attr_key):
            fields = value
    return fields