'Map /in/TAG_NAME/[@<pos>]/ to tag searches.
>>> path = \'/in/inbox/@20/as.json\'
>>> commands = urlmap._map_tag(request, path[1:].split(\'/\'), {}, {})
>>> commands
[<mailpile.plugins.core.Output...>, <mailpile.plugins.search.Search...>]
>>> commands[0].args
(\'as.json\',)
>>> commands[1].args
(\'@20\', \'in:inbox\')'

def _map_tag(self, request, path_parts, query_data, post_data):

    output = self._choose_output(path_parts)
    pos = None
    while (path_parts and (path_parts[(-1)][0] in ('@',))):
        pos = (path_parts[(-1)].startswith('@') and path_parts.pop((-1)))
    tag_slug = '/'.join([p for p in path_parts[1:] if p])
    tag = self.config.get_tag(tag_slug)
    tag_search = ([term for term in (tag.search_terms % tag).split() if term] if (tag is not None) else [('in:%s' % tag_slug)])
    if ((tag is not None) and tag.search_order and ('order' not in query_data)):
        query_data['order'] = [tag.search_order]
    if pos:
        tag_search[:0] = [pos]
    return [output, self._command('search', args=tag_search, query_data=query_data, post_data=post_data)]
