'Map a path to a command list, prefering the longest match.
>>> urlmap._map_api_command(\'GET\', [\'message\', \'draft\', \'\'], {}, {})
[<mailpile.plugins.core.Output...>, <...Draft...>]
>>> urlmap._map_api_command(\'POST\', [\'message\', \'update\', \'\'], {}, {})
[<mailpile.plugins.core.Output...>, <...Update...>]
>>> urlmap._map_api_command(\'GET\', [\'message\', \'update\', \'\'], {}, {})
Traceback (most recent call last):
UsageError: Not available for GET: message/update'

def _map_api_command(self, method, path_parts, query_data, post_data, fmt='html', async=False):

    output = self._choose_output(path_parts, fmt=fmt)
    for bp in reversed(range(1, (len(path_parts) + 1))):
        try:
            return [output, self._command('/'.join(path_parts[:bp]), args=path_parts[bp:], query_data=query_data, post_data=post_data, method=method, async=async)]
        except UsageError:
            pass
        except BadMethodError:
            break
    raise UsageError(('Not    available    for    %s:    %s' % (method, '/'.join(path_parts))))
