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())
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
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
def get_depth(default): return max(1, min(arg_int('depth', default=default), 3))