# Path: flask_restaction/res.py
# def res_to_url(resource, action):
#     """Convert resource.action to (url, HTTP_METHOD)"""
#     i = action.find("_")
#     if i < 0:
#         url = "/" + resource
#         httpmethod = action
#     else:
#         url = "/%s/%s" % (resource, action[i + 1:])
#         httpmethod = action[:i]
#     return url, httpmethod.upper()


import argparse
import os
import requests
from .res import res_to_url



RESJS_DIST = os.path.join(os.path.dirname(__file__), 'resjs/dist')


def parse_meta(meta):
    """
    Parse metadata of API

    Args:
        meta: metadata of API
    Returns:
        tuple(url_prefix, auth_header, resources)
    """
    resources = {}
    for name in meta:
        if name.startswith("$"):
            continue
        resources[name] = resource = {}
        for action in meta[name]:
            if action.startswith("$"):
                continue

# Path: flask_restaction/res.py
# def res_to_url(resource, action):
#     """Convert resource.action to (url, HTTP_METHOD)"""
#     i = action.find("_")
#     if i < 0:
#         url = "/" + resource
#         httpmethod = action
#     else:
#         url = "/%s/%s" % (resource, action[i + 1:])
#         httpmethod = action[:i]
#     return url, httpmethod.upper()


# Path: flask_restaction/cli.py
import argparse
import os
import requests
from .res import res_to_url




RESJS_DIST = os.path.join(os.path.dirname(__file__), 'resjs/dist')


def parse_meta(meta):
    """
    Parse metadata of API

    Args:
        meta: metadata of API
    Returns:
        tuple(url_prefix, auth_header, resources)
    """
    resources = {}
    for name in meta:
        if name.startswith("$"):
            continue
        resources[name] = resource = {}
        for action in meta[name]:
            if action.startswith("$"):
                continue

            url, httpmethod = res_to_url(name, action)