예제 #1
0
def one_package(host, app_name):
    test_list_url = url(host)

    f, headers = urllib.request.urlretrieve(test_list_url)
    l = parselist.convert_list_file_to_json(f, get_hostname(host))
    parser = parselist.hbbjsonparser()
    parser.load_json(l)
    return flask.jsonify(parser.dictionary(app_name))
예제 #2
0
def coder_packages_categories(host, category, coder):
    test_list_url = url(host)

    f, headers = urllib.request.urlretrieve(test_list_url)
    l = parselist.convert_list_file_to_json(f, get_hostname(host))
    parser = parselist.hbbjsonparser()
    parser.load_json(l)
    return flask.jsonify(parser.get_developer_category(category, coder))
예제 #3
0
def all_packages(host):
    test_list_url = url(host)

    f, headers = urllib.request.urlretrieve(test_list_url)
    l = parselist.convert_list_file_to_json(f, get_hostname(host))
    parser = parselist.hbbjsonparser()
    parser.load_json(l)
    return flask.jsonify(l)
예제 #4
0
def v2_packages(host):
    test_list_url = url(host)

    query = request.args.get("query")
    coder = request.args.get("coder")
    category = request.args.get("category")
    package = request.args.get("package")

    f, headers = urllib.request.urlretrieve(test_list_url)
    l = parselist.convert_list_file_to_json(f, get_hostname(host))
    parser = parselist.hbbjsonparser()
    parser.load_json(l)

    # Query
    if query and coder and category:
        return flask.jsonify(
            parser.query_packages_category_coder(query, coder, category))

    if query and coder:
        return flask.jsonify(parser.query_packages_coder(query, coder))

    if query and category:
        return flask.jsonify(parser.query_packages_category(query, category))

    if query:
        return flask.jsonify(parser.query_packages(query))

    # Coder
    if coder and category:
        return flask.jsonify(parser.get_developer_category(category, coder))

    if coder:
        return flask.jsonify(parser.get_developer(coder))

    # Basic
    if category:
        return flask.jsonify(parser.get_category(category))

    if package:
        return flask.jsonify(parser.dictionary(package))

    return flask.jsonify(l)