def read_opt(options, key, required=False, default=None, method='get'):
    """utility to read an attribute from an options dictionary

    Parameters
    ----------
    options : dict
        the option dictionary to read
    key : `str`
        the key to read

    Keyword Args
    ------------
    required : bool
        if true, raise error if the `key` is not in the option dict
    default : object
        a default to return if `key` is not in option dict and `required` is false
    """
    if key in options.keys():
        if method == 'get':
            return options.get(key)
        elif method == 'pop':
            return options.pop(key)
        else:
            raise ValueError('{} is not supported method'.format(method))
    if required:
        raise KeyError(
            'Field "{}" is mandatory. Please provide this field in the options.'
            .format(key))
    return default
