Pull directives out of the specified entry stream.

    :param entrystream: a stream of entries
    :param type: retrieve only directives of the specified type; set to
                 :code:`None` to retrieve all directives

def directives(entrystream, type=None):
    """
    Pull directives out of the specified entry stream.

    :param entrystream: a stream of entries
    :param type: retrieve only directives of the specified type; set to
                 :code:`None` to retrieve all directives
    """
    for directive in entry_type_filter(entrystream, tag.Directive):
        if not type or type == directive.type:
            yield directive