def get_jellyroll_items(parser, token):
    """
    Load jellyroll ``Item`` objects into the context.In the simplest mode, the
    most recent N items will be returned.
    
    ::
    
        {# Fetch 10 most recent items #}
        {% get_jellyroll_items limit 10 as items %}
        
    Newer items will be first in the list (i.e. ordered by timstamp descending)
    unless you ask for them to be reversed::
    
        {# Fetch the 10 earliest items #}
        {% get_jellyroll_items limit 10 reversed as items %}
    
    You can also fetch items between two given dates::
    
        {% get_jellyroll_items between "2007-01-01" and "2007-01-31" as items %}
        
    Dates can be in any format understood by ``dateutil.parser``, and can of
    course be variables. Items must be limited in some way; you must either pass
    ``limit`` or ``between``.
    
    Dates can also be the magic strings "now" or "today"::
    
        {% get_jellyroll_items between "2007-01-01" and "today" as items %}
    
    You can also limit items by type::
    
        {# Fetch the 10 most recent videos and photos #}
        {% get_jellyroll_items oftype video oftype photo limit 10 as items %}
    
    ``oftype`` can be given as many times as you like; only those types will be
    returned. The arguments to ``oftype`` are the lowercased class names of
    jellyroll'd items. 
    
    You can similarly exclude types using ``excludetype``::
    
        {# Fetch the 10 most items that are not videos #}
        {% get_jellyroll_items excludetype video limit 10 as items %}
        
    You can give ``excludetype`` as many times as you like, but it is an error
    to use both ``oftype`` and ``excludetype`` in the same tag invocation.
    """
    
    # Parse out the arguments
    bits = token.split_contents()
    tagname = bits[0]
    bits = iter(bits[1:])
    args = {}
    for bit in bits:
        try:
            if bit == "limit":
                try:
                    args["limit"] = int(bits.next())
                except ValueError:
                    raise template.TemplateSyntaxError("%r tag: 'limit' requires an integer argument" % tagname)
            elif bit == "between":
                args["start"] = bits.next()
                and_ = bits.next()
                args["end"] = bits.next()
                if and_ != "and":
                    raise template.TemplateSyntaxError("%r tag: expected 'and' in 'between' clause, but got %r" % (tagname, and_))
            elif bit == "oftype":
                args.setdefault("oftypes", []).append(bits.next())
            elif bit == "excludetype":
                args.setdefault("excludetypes", []).append(bits.next())
            elif bit == "reversed":
                args["reversed"] = True
            elif bit == "as":
                args["asvar"] = bits.next()
            else:
                raise template.TemplateSyntaxError("%r tag: unknown argument: %r" % (tagname, bit))
        except StopIteration:
            raise template.TemplateSyntaxError("%r tag: an out of arguments when parsing %r clause" % (tagname, bit))
    
    # Make sure "as" was given
    if "asvar" not in args:
        raise template.TemplateSyntaxError("%r tag: missing 'as'" % tagname)
    
    # Either "limit" or "between" has to be specified
    if "limit" not in args and ("start" not in args or "end" not in args):
        raise template.TemplateSyntaxError("%r tag: 'limit' or a full 'between' clause is required" % tagname)
    
    # It's an error to have both "oftype" and "excludetype"
    if "oftype" in args and "excludetype" in args:
        raise template.TemplateSyntaxError("%r tag: can't handle both 'oftype' and 'excludetype'" % tagname)
    
    # Each of the "oftype" and "excludetype" arguments has be a valid model
    for arg in ("oftypes", "excludetypes"):
        if arg in args:
            model_list = []
            for name in args[arg]:
                try:
                    model_list.append(Item.objects.models_by_name[name])
                except __HOLE__:
                    raise template.TemplateSyntaxError("%r tag: invalid model name: %r" % (tagname, name))
            args[arg] = model_list
    
    return GetJellyrollItemsNode(**args)
dataset/ETHPy150Open jacobian-archive/jellyroll/src/jellyroll/templatetags/jellyroll.py/get_jellyroll_items