def new_searcher(attr, tbl, attrid): def _search(self, dq): alias = "ss_" + attr dq.outer("%(t)s %(a)s" % {'t': tbl, 'a': alias}, "(e.id=%(a)s.event AND %(a)s.attr=%(i)d)" % {'a': alias, 'i': attrid}) return alias + ".value" _search.__name__ = "search_" + attr _search.__doc__ = "auto-generated searcher for %s" % (attr,) if tbl == 'rpcc_event_str': return search(attr, StringMatch)(_search) elif tbl == 'rpcc_event_int': return search(attr, IntegerMatch)(_search) else: raise ValueError()
def solve_with_algorithm(choice, maze, loop): if (choice == "1"): times = [] moves = [] times.clear() moves.clear() for i in range(loop): start = time.perf_counter() m.search(maze, 0, 0) end = time.perf_counter() elapsed = (end - start) * 1000.0 times.append(elapsed) moves.append(len(m.visited)) m.reset_search(maze) return times, moves
def searchresult(search_item): if request.method == 'GET': result = model.search(search_item) if result: return render_template('search.html', restaurants = result) else: return render_template('search.html', message = "bad search item")
def searchresult(search_item): if request.method == 'GET': business_ids = model.search(search_item) restaurants = [] for x in business_ids: restaurants.append(model.get_restaurant_data(x[0])) random.shuffle(restaurants) if len(restaurants) > 0: return render_template( 'dashboard.html', restaurants=restaurants[:10], message="Is this the restaurant you are looking for?") else: user_name = '%s' % escape(session['username']) user_name = model.get_id_in_matrix(user_name) if (user_name == None): user_name = model.get_random_username() restaurants = model.get_restaurants(user_name) random.shuffle(restaurants) return render_template( 'dashboard.html', restaurants=restaurants[:10], message= "Restaurant cannot be found but here are some restaurants you may like. " )
def search(): age_group = int(request.args.get("age_group", "1")) sex = int(request.args.get("sex", "1")) diagnosis = request.args.get("diagnosis") data = app_data.search(age_group, sex, diagnosis) return jsonify(data)
def solveMaze(size): grid = model.convert(model.DFS(model.make_empty_maze(size, size))) start = time.time() model.search(1, 1, grid) end = time.time() #print(grid) count = 0 flattened_list = [y for x in grid for y in x] for n in flattened_list: if n == 3 or n == 2: count += 1 t = end - start lis = [t, count] return lis
def new_searcher(attr, tbl, attrid): def _search(self, dq): alias = "ss_" + attr dq.outer( "%(t)s %(a)s" % { 't': tbl, 'a': alias }, "(e.id=%(a)s.event AND %(a)s.attr=%(i)d)" % { 'a': alias, 'i': attrid }) return alias + ".value" _search.__name__ = "search_" + attr _search.__doc__ = "auto-generated searcher for %s" % (attr, ) if tbl == 'rpcc_event_str': return search(attr, StringMatch)(_search) elif tbl == 'rpcc_event_int': return search(attr, IntegerMatch)(_search) else: raise ValueError()
def search_results(): protein = request.form['protein'] residue_number = request.form['residue_number'] dataset = request.form['dataset'] top_10_edges = model.search(protein=protein, residue_number=residue_number, dataset=dataset) return render_template('search_results.html', top_10_edges=top_10_edges, protein=protein, residue_number=residue_number, dataset=dataset)
def show_collection_table(collection): update_visited_pages( 'Tabla de colección', url_for('show_collection_table', collection=collection)) if request.method == 'GET': # Variables GET search_value = request.args.get('search') page = request.args.get('page') # Buscar en MongoDB (si así se indica) not_searching = search_value is None if not_searching: # Datos del cuerpo de la tabla, extraídos de la colección de MongoDB collection_data = model.get_all_entries(collection) else: #return search_value collection_data = model.search(collection, search_value) is_empty = len(collection_data) == 0 # Control página page_num = 1 if (page is None) else max(int(page), 1) last_page = max(len(collection_data) // ENTRIES_PER_PAGE, 1) if page_num > last_page: page_num = last_page is_last_page = (page_num == last_page) is_first_page = (page_num == 1) if is_empty: collection_data_page = [] collection_headers = [] else: collection_data_page = collection_data[(page_num - 1) * ENTRIES_PER_PAGE:page_num * ENTRIES_PER_PAGE] # Cabecera de la tabla (claves de cualquier elemento de la lista) collection_headers = collection_data[0].keys( ) if not is_empty else None return render_template('collection_table.html', collection=collection, data=collection_data_page, data_headers=collection_headers, no_results=is_empty, page=str(page_num), search_value=search_value, prev_page=str(page_num - 1), next_page=str(page_num + 1), is_last_page=is_last_page, is_first_page=is_first_page, not_searching=not_searching)
def doSearch(): # Get the query out of the url. aQuery = request.args.to_dict() # Call another function which will return a python dictionary. aResults = model.search(aQuery) # Return a rendered template with the query and the results. return render_template( "results.html", theQuery=urllib.urlencode(aQuery), theResults=aResults )
def index(): if request.method == "POST": global search_input global path search_input = request.form["search_input"] # print(search_input) id, word, path = search(search_input) if id == 0: return redirect(url_for("error")) if id == 1: hh = search_unit(search_input, path) return redirect(url_for("results")) return render_template("index.html")
def homepage(): """ Return the sites homepage. """ query = request.args.get('query', ''); query = request.headers.get('x-mxit-user-input', query) query = urllib.unquote(query).replace('+', ' ').replace('-', ' ') if (query): track('view_search_results', request, query=query) mxit_ga.track_event(request) results = model.search(query, limit=8) track('search', request, results_length=len(results), query=query) return render_template('search_results.html', results=results, query=query) else: track('view_homepage', request) return render_template('index.html')
import model while True: command = input() parameters = command.split() if parameters[0] == "cwd": model.cwd() elif parameters[0] == "browser": if (len(parameters) == 1): model.browser() else: model.browser(parameters[1]) elif parameters[0] == "search": model.search(parameters[1:]) elif parameters[0] == "image": model.image(parameters[1:]) else: print("Invalid option")
def index(): terms = set() photos = [] while len(terms) != 3: terms.add(m.getPhotoTerm()) for i in terms: photos.append(m.getPhoto(i)) global link if request.method == "GET": resIDs.clear() find = m.search(m.getRandom(), 'NYC') res = m.getDetails(find['businesses'][0]['id']) # print(res) link = res['url'] try: price = "(" + res["price"] + ")" except (KeyError, TypeError): price = "" params = { 'name': res['name'], 'price': price, 'img1': res['photos'][0], 'img2': res['photos'][1], 'img3': res['photos'][2], 'rating': m.getRating(res['rating']), 'reviewCount': res['review_count'], 'address': res['location']['display_address'][0] + ", " + res['location']['display_address'][1], 'categories': res['categories'], 'terms': list(terms), 'photos': photos, 'KEY': API_KEY } return render_template('index.html', time=datetime.now(), **params) else: if request.form['formType'] == "initial": termList = [] if request.form['term'] != "": termList.append(request.form['term']) try: termList.append(request.form["term1"]) except (KeyError): pass try: termList.append(request.form["term2"]) except (KeyError): pass try: termList.append(request.form["term3"]) except (KeyError): pass # print(request.form) print(termList) loc = request.form["loc"] for i in termList: find = m.search(i, loc, 5) for j in find['businesses']: resIDs.append(j['id']) res = m.getDetails(resIDs.pop(0)) elif request.form['formType'] == "no": # print(resIDs) if resIDs: res = m.getDetails(resIDs.pop(0)) else: find = m.search(m.getRandom(), 'NYC') res = m.getDetails(find['businesses'][0]['id']) elif request.form['formType'] == 'yes': return redirect(link) link = res['url'] try: price = "(" + res["price"] + ")" except (KeyError): price = "" params = { 'name': res['name'], 'price': price, 'img1': res['photos'][0], 'img2': res['photos'][1], 'img3': res['photos'][2], 'rating': m.getRating(res['rating']), 'reviewCount': res['review_count'], 'address': res['location']['display_address'][0] + ", " + res['location']['display_address'][1], 'categories': res['categories'], 'terms': list(terms), 'photos': photos, 'KEY': API_KEY } return render_template("index.html", time=datetime.now(), **params)
def search_route(): return search(request.args.get("token"), request.args.get("query_str"))
def start_search(): global START_FLAG if not START_FLAG: self.re_plot() START_FLAG = False mo.search(self, cf.START, cf.GOAL)
def search(search_term): search_results = model.search(search_term) return jsonify(dict(search_results=search_results))
def POST(self): i = web.input() q = i.q results = model.search(q) return render.search(formSearch,results)
def start_search(): self.init_grid() self.re_plot() mo.search(self, self.alg.get())