示例#1
0
def match():
    dataset_arg = request.args.get('dataset')
    dataset = Dataset.find(dataset_arg)
    matches = find_matches(dataset,
                           request.args.get('name'),
                           filter=request.args.get('filter'),
                           exclude=arg_int('exclude'))
    pager = Pager(matches)
    return jsonify(pager.to_dict())
示例#2
0
def match():
    dataset_arg = request.args.get('dataset')
    dataset = Dataset.find(dataset_arg)
    matches = find_matches(dataset,
                           request.args.get('name'),
                           filter=request.args.get('filter'),
                           exclude=arg_int('exclude'))
    pager = Pager(matches)
    return jsonify(pager.to_dict())
示例#3
0
def paginate_graph(graph):
    graph.partial = None
    limit = arg_int('limit')
    if limit is None or graph.number_of_nodes() <= limit:
        return graph

    graph.partial = {'total': graph.number_of_nodes(), 'shown': limit}
    nodes = sorted(graph.nodes_iter(data=True),
                   key=lambda (id, d): d['degree'],
                   reverse=True)
    for id, data in nodes[limit:]:
        graph.remove_node(id)
    return graph
示例#4
0
def paginate_graph(graph):
    graph.partial = None
    limit = arg_int('limit')
    if limit is None or graph.number_of_nodes() <= limit:
        return graph

    graph.partial = {
        'total': graph.number_of_nodes(),
        'shown': limit
    }
    nodes = sorted(graph.nodes_iter(data=True),
                   key=lambda (id, d): d['degree'],
                   reverse=True)
    for id, data in nodes[limit:]:
        graph.remove_node(id)
    return graph
示例#5
0
def get_depth(default):
    return max(1, min(arg_int('depth', default=default), 3))
示例#6
0
def get_depth(default):
    return max(1, min(arg_int('depth', default=default), 3))