• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python search.search函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中search.search函数的典型用法代码示例。如果您正苦于以下问题:Python search函数的具体用法?Python search怎么用?Python search使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了search函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: search_

def search_(search_query):
    search_results = search(search_query)

    and_ids = search(search_query)['ands']
    or_ids = search(search_query)['ors']

    #Each key in 'ands' and 'ors' has a list of integers that represent
    #the ids of the meteorites.

    ands = {'countries': [], 'meteorites': [], 'classifications': []}
    ors = {'countries': [], 'meteorites': [], 'classifications': []}

    for model, ids in and_ids.items():
        for id in ids:
            m_info = requests.get('http://meteorite-landings.me/api/' + model + '/' + str(id)).json()
            ands[model].append(m_info)


    for values in or_ids.values():
        for model, ids in values.items():
            for id in ids:
                m_info = requests.get('http://meteorite-landings.me/api/' + model + '/' + str(id)).json()
                ors[model].append(m_info)

    return jsonify(ors = ors, ands = ands)
开发者ID:Leith24,项目名称:cs373-idb,代码行数:25,代码来源:app.py


示例2: search_with_start

def search_with_start(start_ind):
    t_routes = []
    this_start = start_ind[0]
    this_end = start_ind[1]
    print(start_ind)
    start_time = time.time()
    for ind in range(this_start, this_end + 1):
        print('Process ' + str(start_ind[2]) + ': start number ' + str(ind))
        a = len(t_routes)
        search.search(search.normalOrders.index[ind])
        t_nodes, t_times = search.resultsNodes, search.resultsTime
        t_routes += merge.format_transform(t_nodes, t_times, search.orders)
        print('Process ' + str(start_ind[2]) + ': end number ' + str(ind) +
              ' with start length ' + str(a) + ' end length ' + str(len(t_routes)) +
              ' add ' + str(len(t_nodes)))
        clear_search_results()
        now_time = time.time()
        if now_time - start_time >= 1200.0:
            f1 = open('temp_res/ori_routes' + str(start_ind[2]), 'wb')
            pickle.dump((ind, this_end, t_routes), f1)
            f1.close()
            start_time = now_time
    f1 = open('temp_res/ori_routes_C' + str(start_ind[2]), 'wb')
    pickle.dump(t_routes, f1)
    f1.close()
    return t_routes
开发者ID:shinsyzgz,项目名称:429A,代码行数:26,代码来源:main.py


示例3: test_search

 def test_search(self):
     search.search(base.get_dbo(), FakeSession(), "test")
     keywords = [ "os", "notforadoption", "notmicrochipped", "hold", "quarantine", "deceased", 
         "forpublish", "people", "vets", "retailers", "staff", "fosterers", "volunteers", "shelters",
         "aco", "homechecked", "homecheckers", "members", "donors", "reservenohomecheck",
         "overduedonations", "activelost", "activefound" ]
     for k in keywords:
         search.search(base.get_dbo(), FakeSession(), k)
开发者ID:magul,项目名称:asm3,代码行数:8,代码来源:test_search.py


示例4: do_GET

    def do_GET(self):
        global squid_hostname
        global squid_port
        global google_domain
        global yahoo_domain
        global keyword
        
        parts = self.path.split("?") #Extract requested file and get parameters from path
        path = parts[0]
        
        #Extract variables from get parameters
        try:
            arguments = {}
            arguments["q"] = None #Variable for search request. Default None to prevent errors if no search request was started
            if (len(parts) > 1):
                raw_arguments = parts[1].split("&")
                for raw_argument in raw_arguments[:]:
                    argument = raw_argument.split("=", 1)
                    arguments[argument[0]] = argument[1]
                    if (argument[0] == "p"): # Yahoo uses search?p= so lets copy that to q=, which is what Google uses.
                        arguments["q"] = argument[1]
        except:
            print ("No get parameters")
        
        print (path)
        
        #Decide wether a search or the style.css was requested
        if (path == "/style.css"):
            self.document = open('style.css', 'r').read()
            self.send_response(200)
            self.send_header('Content-type', 'text/html')
            self.end_headers()
            self.wfile.write(bytes(self.document, "utf-8"))
        elif (path == "/proxy.pac"):
            self.document = open('proxy.pac', 'r').read()
            self.document = self.document.replace('<keyword>', keyword.lower(), 1)
            self.document = self.document.replace('<google_domain>', google_domain, 1)
            self.document = self.document.replace('<yahoo_domain>', yahoo_domain, 1)
            self.document = self.document.replace('<squid_host>', squid_hostname, 2)
            self.document = self.document.replace('<squid_port>', str(squid_port), 2)
            self.send_response(200)
            self.send_header('Content-type', 'x-ns-proxy-autoconfig')
            self.end_headers()
            self.wfile.write(bytes(self.document, "utf-8"))
        elif (arguments["q"] != None):
            arguments["q"] = arguments["q"].replace(keyword + '+', '', 1)
            arguments["q"] = arguments["q"].replace('+', ' ')
            arguments["q"] = arguments["q"].replace('! ', '')
            command = commands(self)
            search(command).search(arguments["q"])
        else:
            self.send_response(404)
            self.send_header('Content-type', 'text/html')
            self.end_headers()
            self.wfile.write(bytes('Not found. Please visit <a href="https://github.com/HcDevel/Siri-API/wiki/_pages">https://github.com/HcDevel/Siri-API/wiki/_pages</a>', "utf-8"))

        return
开发者ID:Hackworth,项目名称:Siri-API,代码行数:57,代码来源:server.py


示例5: main

def main():
    opts = read_opts()

    if not opts.c_backend:
        print "WARNING: training in pure python. Run with -c option to enable the (much faster) C++ backend"

    feature_descriptors = faces.list_feature_descriptors((16, 16))
    data = []
    print "loading faces..."
    faces.load_data_dir("Face16", 1, feature_descriptors, data, opts.num_faces, opts.c_backend)
    faces.load_data_dir("Nonface16", -1, feature_descriptors, data, opts.num_other, opts.c_backend)

    print "suffling..."
    random.shuffle(data)
    if opts.sample_size:
        train_data = data[: opts.sample_size]
        validation_data = data[opts.sample_size : opts.sample_size + opts.validate_size]
    elif opts.validate_size:
        train_data = []
        validation_data = data[: opts.validate_size]
    else:
        train_data = data
        validation_data = []

    if opts.load_classifier:
        with open(opts.load_classifier) as in_file:
            classifier = serializer.load(in_file)
    else:
        print "training boosted classifier..."
        if not train_data:
            print "specify some training data with the -s flag."
            exit(1)
        classifier = boost.train_classifier(train_data, opts.num_iterations)
        print classifier

    if train_data:
        print "training error:"
        classify(classifier, train_data)

    if validation_data:
        print "validation error:"
        if opts.each_iter:
            classify_with_all_iterations(classifier, validation_data, opts.plot_iters)
        else:
            classify(classifier, validation_data)

    if opts.plot_features:
        plot_features(classifier, feature_descriptors)

    if opts.search_image:
        search.search(classifier, opts.search_image, feature_descriptors, opts.c_backend)

    if opts.save_classifier:
        with open(opts.save_classifier, "w") as out_file:
            serializer.dump(classifier, out_file)
开发者ID:catphive,项目名称:face_detector,代码行数:55,代码来源:driver.py


示例6: search

 def search(self, item):
     print "SEARCH"
     add_here(history_list[self.window_index][here[self.window_index][0]][0], self.window_index)
     if history_list[self.window_index][here[self.window_index][0]][0] != "*\\*":
         result = search(str(item), history_list[self.window_index][here[self.window_index][0]][0])
     else:
         result = search(str(item), history_list[self.window_index][here[self.window_index][0] - 1][0])
     print result
     if result:
         self.ui.listView.clear()
         listView(result, self.ui.listView)
         add_here("*\\*", self.window_index)
开发者ID:mrbahrani,项目名称:File-Managment-AP-Project,代码行数:12,代码来源:app.py


示例7: testDateSearch

 def testDateSearch(self):
     self.assertEquals([["# 0001-01-01\n", "{0}   \n".format(write.time)
                         + write.prepareContent("Start of datesearch")],
                        ["# 0015-01-01\n", "{0}   \n".format(write.time)
                         + write.prepareContent("Middle of datesearch")]],
                        search.search("", "0001-01-01", "0015-01-01"))
     self.assertEquals([["# 0001-01-01\n", "{0}   \n".format(write.time)
                         + write.prepareContent("Start of datesearch")],
                        ["# 0015-01-01\n", "{0}   \n".format(write.time)
                         + write.prepareContent("Middle of datesearch")],
                        ["# 0031-01-01\n", "{0}   \n".format(write.time)
                         + write.prepareContent("End of datesearch")]],
                        search.search("", "0001-01-01", "0031-01-01"))
开发者ID:fahrstuhl,项目名称:diarium,代码行数:13,代码来源:searchTest.py


示例8: do_GET

	def do_GET(self):
		parsed_path = urlparse.urlparse(self.path)
		# res = []
		res = {}

		if parsed_path.path == '/analyze':
			url = parsed_path.query.split('=')[1]
			while isShorten(url) == True:
				_, url = get(url)
			res['url'] = url
			prot, domain, path = parseURL(url)
			res['evil'] = isEvil(domain)
			num, title, content = search(url)
			res['num'] = num
			res['title'] = title
			res['content'] = content
			if prot != 'https':
				res['grade'] = 'F'
			else:
				res['grade'] = grading(url)
		elif parsed_path.path == '/expand':
			url = parsed_path.query.split('=')[1]
			while isShorten(url) == True:
				_, url = get(url)
			res['url'] = url
		elif parsed_path.path == '/check':
			url = parsed_path.query.split('=')[1]
			_, domain, _=parseURL(url)
			res['evil'] = isEvil(domain)
		elif parsed_path.path == '/grade':
			url = parsed_path.query.split('=')[1]
			while isShorten(url) == True:
				_, url = get(url)
			print('URL:', url)
			grade = grading(url)
			res['grade'] = grade
			print('Grade:', grade)
		elif parsed_path.path == '/search':
			url = parsed_path.query.split('=')[1]
			num, title, content = search(url)
			res['num'] = num
			res['title'] = title
			res['content'] = content
			# print('Content:', content.decode('utf-8'))
		
		self.send_response(200)
		self.end_headers()
		result = makeHTML(json.dumps(res))
		self.wfile.write(result.encode('utf-8'))
		return
开发者ID:whlinw,项目名称:CNS-Final,代码行数:50,代码来源:server.py


示例9: solve

def solve(totals, goal, init=None):
    '''
    Search for shortest path to solve the pouring problem.

    totals -- a tuple of capacities (numbers) of glasses

    goal -- a number indicating the volume level we want 
            to have any one of the glasses contain

    init -- optional tuple of initial levels for each glass

    If start is not specified, we set the starting levels of each 
    glass to zero.

    We start the search at the start state and follow paths of 
    successor states (generated by `next`) until we reach the goal.

    After reaching the goal state, we return the shortest path
    found, a sequence of states from start to goal state.

    '''
    done = lambda state: state.contains(goal)
    init = init or tuple(0 for t in totals)
    glasses = (Glass(i,t) for i,t in zip(init, totals))
    start = State(Glasses(glasses), action=None)
    return search(start, next, done)
开发者ID:joyrexus,项目名称:CS212,代码行数:26,代码来源:main.py


示例10: find

def find():
    from search import search

    fromEnvVars = FromEnvVars( name, description, hints = "CCTBX_ROOT" )

    paths = search( [fromEnvVars] )
    return paths
开发者ID:danse-inelastic,项目名称:build_utils,代码行数:7,代码来源:Cctbx.py


示例11: main

def main():
    arguments = docopt(doc, version='Python Package Manager 0.1')
    if arguments['install']:
        if arguments['<package>']:
            install(arguments['<package>'])
        else:
            #find requirements.txt
            #find package.json
            #load dependence list
            #call install for all deps
            pass
    elif arguments['search']:
        if arguments['<package>']:
            search(arguments['<package>'])

    return 1
开发者ID:guilhermebr,项目名称:ppm,代码行数:16,代码来源:__init__.py


示例12: search_results

def search_results(page, mentee_topic_choice=None):
    mentee_topic_choice = mentee_topic_choice or request.form.get("searchtopics")
    print "~~~~~~~~~~~~~~~~mentee_topic_choice"
    print mentee_topic_choice
    mentor_data = search.search(mentee_topic_choice)
    if mentor_data:

        start_index = (page - 1) * (PER_PAGE)
        end_index = (page) * (PER_PAGE)

        ment_count = len(mentor_data)
        users = mentor_data[start_index:end_index]
        # users = mentor_data.paginate(page, PER_PAGE, False)

        if not users and page != 1:
            abort(404)
        pagination_per_page = pagination.Pagination(page, PER_PAGE, ment_count)
        search_topic = search.search_topic_display(mentee_topic_choice)
        return render_template(
            "searchresults.html",
            search_topic_display=search_topic,
            pagination=pagination_per_page,
            users=users,
            mentee_topic_choice=mentee_topic_choice,
        )
    messages = flash("Sorry! There are no mentors under this search topic")
    return redirect(url_for("index"))
开发者ID:awakwe,项目名称:MentoreeMatch,代码行数:27,代码来源:main.py


示例13: searchView

def searchView(request):
  """
  Renders search.html using the search results of a query entered
  into the search bar

  @type request: string
  @param request: An HTML request

  @rtype: HTML page
  @return: Rendered version of search.html
  """

  sform = SearchForm(request.POST)

  # Ensure form is valid
  if not sform.is_valid():
    return index(request)

  user_query = sform.cleaned_data['search_query']

  # Get search results. Format: [ MatchObject, MatchObject, ...]
  search_result = search(user_query)

  # Construct a dictionary from search results to pass along to html template
  search_dict = {"results" : [], "query" : ''}
  for match in search_result :
    # Make list for each MatchObject in search_result.
    # List format = [MatchObject, type of object, name of object, [LiObject, LiObject, ...] ]
    result_list = [match]
    result_list.extend(getTypeNameImage(match.idref))

    search_dict["results"].append(result_list)
  search_dict["query"] = sform.cleaned_data['search_query']

  return render(request, 'wcdb/search.html', search_dict)
开发者ID:bblee1002,项目名称:cs373-wcdb,代码行数:35,代码来源:views.py


示例14: DO_PLUGIN_SEARCH

    def DO_PLUGIN_SEARCH(self, args, criterion, exact):
        search_terms = args
        url = "http://sourcemod.net/plugins.php?search=1&%s=%s" % (criterion, search_terms)

        db_search_terms = search_terms.replace("%", "\\%").replace("*", "%")
        if not exact:
            db_search_terms = "%" + db_search_terms + "%"

        search_args = {criterion: db_search_terms}
        plugins = search.search(**search_args)

        length = len(plugins)
        if length == 0:
            # No results found
            return "No results found for \x02%s\x02" % (args)
        elif length == 1:
            plugin = plugins[0]
            return "\x02%s\x02, by %s: %s  " "( http://forums.alliedmods.net/showthread.php?p=%s )" % (
                plugin["title"],
                plugin["author"],
                plugin["description"],
                plugin["postid"],
            )
        elif length < 7:
            return "Displaying \x02%d\x02 results: %s ( %s )" % (
                length,
                ",".join(map(lambda o: o["title"], plugins)),
                url,
            )
        else:
            return "First \x026\x02 results of \x02%d\x02: %s ( %s )" % (
                length,
                ", ".join(map(lambda o: o["title"], plugins[:6])),
                url,
            )
开发者ID:theY4Kman,项目名称:Yakbot-plugins,代码行数:35,代码来源:plugin.py


示例15: test_good_bridge_response

    def test_good_bridge_response(self):
        """When the bridge response is good, good response_header, result and user_data should be constructed and returned."""
        # Set bridge response text to be good JSON.
        mock_bridge_response = MockBridgeResponse()
        mock_bridge_response.text = '{"search_result": {"results_good": true, "primary_parametric_fields": ["good"]}}'

        mock_requests_get = mock.MagicMock(
            name="mock_requests_get", return_value=mock_bridge_response)
        mock_get_http_headers = mock.MagicMock(
            name='mock_get_http_headers', return_value={})

        with mock.patch('requests.get', mock_requests_get):
            with mock.patch('serpng.lib.http_utils.get_http_headers', mock_get_http_headers):
                # result_sj added for SJ Ads A/B test.
                response_headers, result, result_sj, user_data = search.search(
                    request=MockRequest(), query=MockQuery())

                expected_search_result = MockSearchResult(
                    request=MockRequest(),
                    search_result_json={'results_good': True, 'primary_parametric_fields': ['good']},
                    bridge_search_query=''
                )
                self.assertEqual(expected_search_result, result)

                expected_user_data = MockUserData(
                    json_response={'search_result': {'results_good': True, 'primary_parametric_fields': ['good']}}
                )
                self.assertEqual(expected_user_data, user_data)

                self.assertEqual(response_headers, {'a': 'b'})
开发者ID:alyago,项目名称:django-web,代码行数:30,代码来源:search_tests.py


示例16: test_bridge_has_shab_cookie

    def test_bridge_has_shab_cookie(self):
        """
        When bridge has shab cookie, abtest_manager.reload should be called and
        shab cookie should be removed from bridge response headers.
        """
        # Set bridge response text to be good JSON.
        mock_bridge_response = MockBridgeResponseWithShabCookie()
        mock_bridge_response.text = '{"search_result": {"results_good": true, "primary_parametric_fields": ["good"]}}'

        mock_requests_get = mock.MagicMock(
            name="mock_requests_get", return_value=mock_bridge_response)
        mock_get_http_headers = mock.MagicMock(
            name='mock_get_http_headers', return_value={})

        with mock.patch('requests.get', mock_requests_get):
            with mock.patch('serpng.lib.http_utils.get_http_headers', mock_get_http_headers):
                mock_request = MockRequest()
                mock_request.abtest_manager.reload_cookie = mock.MagicMock(name='mock_reload_cookie')

                # pylint: disable=W0612
                # (result and user_data are not tested in this test case)

                # result_sj added for SJ Ads A/B test. 
                response_headers, result, result_sj, user_data = search.search(
                    request=mock_request, query=MockQuery())

                mock_request.abtest_manager.reload_cookie.assert_called_with('shab_val', True)
                self.assertEqual(response_headers, {'set-cookie': 'has_comma has_comma, no_comma no_comma'})
开发者ID:alyago,项目名称:django-web,代码行数:28,代码来源:search_tests.py


示例17: websearch

def websearch(bot, data):
    """Search the web for a query.

    use ! to send result to channel, and @ to receive as personal message
    """
    if data["message"][0] == "!":
	query = data["message"].replace("!search ", "")
	destination = "to"
    else: 
	query = data["message"].replace("@search ", "")
	destination = "from"
    
    try:
	results = search.search(query)
    except URLError:
	bot.send("Sorry, I dun goofed",channel=data[destination])
	return
    
    if (results == []):
	bot.send("No search results for \"{}\"".format(query),
		 channel=data[destination])
	return
    
    bot.send("Web results for \"{}\":".format(query),channel=data[destination])
    
    for result in results:
	bot.send("* {}: {}".format(result[0], result[1]), channel=data[destination])
开发者ID:Jbalkind,项目名称:gucs-bot,代码行数:27,代码来源:callbacks.py


示例18: search_search

def search_search():
    query = request.args.get('q')
    start = request.args.get('from')
    size = request.args.get('size')
    # return render_template('search.html.jinja2', results=search.search('scrapi', query, start, size))
    results, count = search.search('scrapi', query, start, size)
    return json.dumps(results)
开发者ID:chrisseto,项目名称:scrapi,代码行数:7,代码来源:main.py


示例19: search

    def search(self, searchParam={}):
        """
        search is the main function: it is processing the request and put the element in the queue
        """
        #self.initVoteThreads()
        searchResult = []
        pageLimit = self.constants["BASE_CONFIG"]["search_page_limit"]
        if "searchParams" in self.enviroment_variables["configValues"]:
            if "pageLimit" in self.enviroment_variables["configValues"]["searchParams"]:
                pageLimit = self.enviroment_variables["configValues"]["searchParams"]["pageLimit"]

        # put the request in a queue, so we can have multithread searching for multiaccount
        for page in xrange(1, pageLimit+1):
            self.logger.info("Request for " + searchParam["term"] + " type: " + searchParam["typeSearch"] + " sort: " + searchParam["sort"] + " page: " + str(page))
            tmpSearchArray = search(self, term=searchParam["term"], typeSearch=searchParam["typeSearch"], sort=searchParam["sort"], categories=searchParam["categories"], page=page)
            if len(tmpSearchArray) > 0 and searchParam["typeSearch"] in tmpSearchArray and len(tmpSearchArray[searchParam["typeSearch"]]) > 0:
                for item in tmpSearchArray[searchParam["typeSearch"]]:
                    # check if i can vote and if i can comment and i can follow
                    # need to check in config
                    # put it in a function...
                    self.constants["QUEUE_VOTE"].put(item)
                    self.constants["QUEUE_COMMENT"].put(item)
                    # self.constants["QUEUE_FOLLOW"].put(self.follow(item))
                
                searchResult = searchResult + tmpSearchArray[searchParam["typeSearch"]]
            
            time.sleep(randint(15, 35)) # I need to wait some seconds to do another search
        
        # add result in all active queue and|or in file

        return searchResult
开发者ID:TheJoin95,项目名称:500px-photo-map,代码行数:31,代码来源:api.py


示例20: do_GET

    def do_GET(self):
        start = time.time()
        out = codecs.getwriter("utf-8")(self.wfile, 'xmlcharrefreplace')

        self.send_response(200, "OK")
        self.send_header("Content-Type", "text/xml")
        self.end_headers()

        out.write('<?xml version="1.0" encoding="utf-8" ?>')

        query = urlparse.urlparse(self.path).query
        params = urlparse.parse_qs(query)

        search.search(params, self.wfile)
        end = time.time()
        print >>sys.stderr, "Elapsed:", end - start
开发者ID:Sindbag,项目名称:ruscorpora_tagging,代码行数:16,代码来源:server.py



注:本文中的search.search函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python search.Search类代码示例发布时间:2022-05-27
下一篇:
Python search.breadthFirstSearch函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap