当前位置: 首页>>代码示例>>Python>>正文


Python Search类代码示例

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


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

示例1: true

 def true(self, CE, mapping_list):
     assert len(mapping_list) >0
     
     nmapping_list = []
     for mapping in mapping_list:
         new_self = deepcopy(self)
         assert new_self == self
         for i in range(len(self.args)):
             new_self.args[i] = self.args[i].unify(mapping)
             
         #print 'Searching for %s' % self
         if len(Search.determination_list(CE, new_self)) == 0:
             continue
         
         if Search.search_true(CE, self) is True:
             nmapping_uf = Search.search_true(CE, self, return_mapping=True)
             nmapping = {}
             for a,b in nmapping_uf.items():
                 #print a,b
                 if isinstance(a, Atom):
                     nmapping[b]=a
                 else:
                     nmapping[a]=b
                     
             nmapping_list.append(dict(mapping.items() + nmapping.items()))
     #print self, mapping_list, nmapping_list
     return len(nmapping_list) > 0, nmapping_list
开发者ID:c00w,项目名称:PrologPlus,代码行数:27,代码来源:Types.py

示例2: highQuality

    def highQuality(self):
        global COUNTER
        
        #Search scraper  
        Search.search()

        #Displaying a window massage, telling the user to select their background image
        displayBackgroundMessage()
        imagePath = getImagePath()
        tileFolder = "ImageTiles"
        image = Image.open(imagePath)
        width = image.size[0]
        size = getMuilt(width)

        build_mosaic(
            input_path = imagePath,
            output_path="mosaicImage"+str(COUNTER)+".png",
            collection_path= tileFolder,
            #Enlarge image
            zoom = size,
            #Tile size
            thumb_size = 20,
            fuzz=10,
            new_colormap=False
        )

        COUNTER +=1
        displayFinishMessage()
开发者ID:ThaliaVillalobos,项目名称:Project2Team60,代码行数:28,代码来源:FinalMosaic.py

示例3: write

def write():

    
    #first finger scan
    setBaud()    
    data = genImg.getHeader()
    ser.write(bytearray(data));
    time.sleep(1)
    s = ser.read(ser.inWaiting())
    print([hex(ord(c)) for c in s])
    genImg.parse(s)
    # generate character file of the finger image.
    setBaud()
    data = Img2Tz.getHeader(0x01)
    ser.write(bytearray(data));
    time.sleep(1)
    s = ser.read(ser.inWaiting())
    print([hex(ord(c)) for c in s])
    Img2Tz.parse(s)

    setBaud()
    data = Search.getHeader(0x01, 0x0000, 0x0064)
    ser.write(bytearray(data));
    time.sleep(1)
    s = ser.read(ser.inWaiting())
    print([hex(ord(c)) for c in s])
    print Search.parse(s)
开发者ID:girish946,项目名称:python3-R305,代码行数:27,代码来源:Verify.py

示例4: ui

def ui(inp):
    # Handle search text

    if Search.text == "":
        if inp == curses.KEY_UP:
            ChannelBox.updateChannelBox(0)
        if inp == curses.KEY_DOWN:
            ChannelBox.updateChannelBox(1)
            
    if (inp == curses.ascii.BS) or (inp == curses.ascii.SP):
        Search.update(inp)
        if (Search.text == ""):
            ChannelBox.updateChannelBox(inp)
        else:
            ChannelBox.fillSearchBox(Search.text, inp)
            
    if ((inp >= 65 and inp <=90) or (inp >= 97 and inp <= 122)) or (inp >=48 and inp <=57):
        Search.update(inp)
        ChannelBox.fillSearchBox(Search.text, inp)
    elif not(Search.text == ""):
        if inp == curses.KEY_UP:
            ChannelBox.fillSearchBox(Search.text, 0)
        if inp == curses.KEY_DOWN:
            ChannelBox.fillSearchBox(Search.text, 1)
    if inp == curses.ascii.ESC:
            exit()

    if inp == curses.KEY_ENTER:
        row = ChannelBox.getSelectedRow()
        Utils.startPlaying(row[3])
开发者ID:jaydenmilne,项目名称:SetTopPi,代码行数:30,代码来源:WatchTV.py

示例5: search

def search(init_param):
    try:
        Path.Check(init_param['output.path'])
        
        if platform.system() == 'Linux':
            bat_file = os.path.join(init_param['output.path'], 'normal.bash')
            bat_fp = open(bat_file, 'w')
            bat_fp.write('export PATH=%s:$PATH\n' % ClusterSetting.MPIPath) #modified 2012.6.11
            bat_fp.write('export LD_LIBRARY_PATH=%s:$LD_LIBRARY_PATH\n' % ClusterSetting.pLinkBinPath)
        elif platform.system() == 'Windows':
            bat_file = os.path.join(init_param['output.path'], 'normal.bat')
            bat_fp = open(bat_file, 'w')
            bat_fp.write('@echo off\n')
            bat_fp.write('%s\n' % init_param['bin.path'][0:2])
        else:
            raise Exception('search_and_filter', 'unknown platform, only support Windows and Linux')
        
        bat_fp.write('cd "%s"\n' % init_param['bin.path'])
        
        search_mode = string.atoi(init_param['search_mode'])
        pfind_param = Search._ConstructpFindParam(init_param, search_mode, init_param['output.path'])
        print 'Step : Search by Searcher'
        spectra_list = init_param['spectra_list']
        spectra_title = init_param['spectra.title']
        bin_path = init_param['bin.path']
        
        for i in range(0, len(init_param['spectra_list'])):
            pfind_file = os.path.join(init_param['output.path'], '%s%d.pfind' % (init_param['spectra.title'], i+1))
            pfind_result_file = os.path.join(init_param['output.path'], '%s%d_qry.proteins.txt' % (init_param['spectra.title'], i+1))
    
            if os.path.isfile(pfind_result_file):
                print os.path.split(pfind_result_file)[-1] + ' did exist, skip the step';
            else:
                print 'Searcher of '+ spectra_list[i];
                spectrum = []
                spectrum.append(('spec_title', spectra_title+'%d' %(i+1)))
                spectrum.append(('spec_type', '%s' % init_param['spectra.format'].upper()))
                spectrum.append(('spec_path', spectra_list[i]))
                pfind_param['spectrum'] = spectrum
                
                Search._WritepFind(pfind_param, pfind_file, search_mode)
                if platform.system() == 'Windows':
                    bat_fp.write('"%s" "%s"\n' % (os.path.join(bin_path,'Searcher'), pfind_file))
                else:
                    bat_fp.write('"%s" "%s"\n' % (os.path.join(bin_path,'Importer'), pfind_file))
                    if 'mpicores' in init_param:
                        mpicores = init_param['mpicores']
                    else:
                        mpicores = ClusterSetting.DefaultCores
                    if 'mpihosts' in init_param:
                        mpihosts = init_param['mpihosts']
                    else:
                        mpihosts = ClusterSetting.DefaultHosts
                    bat_fp.write('mpirun -np %s -host %s "%s" "%s"\n' %(mpicores, mpihosts, os.path.join(bin_path,'MPISearcher'), pfind_file))
        bat_fp.close()

    except Exception, e:
        print Exception + ": " + e
开发者ID:pLinkSS,项目名称:pLink-SS,代码行数:58,代码来源:Disulfide.py

示例6: main_page

	def main_page(self):
		import Search
		#add to the user the bleats he follows
		for listening in self.listens:
			following = Search.search_user_by_ID_e(listening)
			for bleats in following.bleats:
				self.add_bleats(bleats)
		#add to the user the bleats mentioning him
		bleat_list = Search.search_bleat_by_content("@"+self.username)
		for bleat in bleat_list:
			self.add_bleats(bleat)
开发者ID:noRubidium,项目名称:COMP2041_ass2,代码行数:11,代码来源:Html.py

示例7: default

 def default(self, line):
     if len(line) == 0:
         return
         
     if line[-1] == '?':
         print Search.search(self.CE, Parser._parse_pred(line[:-1]))
         return
         
     try:
         self.CE.update(Parser._parse(line))
         print 'Accepted'
     except:
         print traceback.format_exc()
开发者ID:c00w,项目名称:PrologPlus,代码行数:13,代码来源:Interpreter.py

示例8: menu

def menu(host, T, t_host):
	while True:
		print ("Scegli azione PEER:\nlogin\t - Login\nquit\t - Quit\n\n")
		choice = input()

		if (choice == "login" or choice == "l"):
			t_host, sessionID = logi.login(host, t_host)
			if sessionID != bytes(const.ERROR_LOG, "ascii"):
				tfunc.success("Session ID: " + str(sessionID, "ascii"))

				listPartOwned = {}

				daemonThreadP = daemon.PeerDaemon(host, listPartOwned)
				daemonThreadP.setName("DAEMON PEER")
				daemonThreadP.setDaemon(True)
				daemonThreadP.start()

				waitingDownload = []

				while True:
					if len(waitingDownload) == 0:
						print ("\n\nScegli azione PEER LOGGATO:\nadd\t - Add File\nsearch\t - Search and Download\nlogout\t - Logout\n\n")
						choice_after_log = input()

						if (choice_after_log == "add" or choice_after_log == "a"):
							add.add(host, sessionID, t_host, listPartOwned)

						elif (choice_after_log == "search" or choice_after_log == "s"):
							src.search(sessionID, host, t_host, listPartOwned, waitingDownload)

						elif (choice_after_log == "logout" or choice_after_log == "l"):
							if (logo.logout(host, t_host, sessionID) > 0):

								break

						else:
							tfunc.error("Wrong Choice!")
					else:
						time.sleep(1)

			else:
				tfunc.error("Errore Login")	

		elif (choice == "quit" or choice == "q"):
			if T:
				logo.quit(host)
			break

		else:
			tfunc.error("Wrong Choice")
开发者ID:tommasoberlose,项目名称:p2p_bittorrent,代码行数:50,代码来源:Menu.py

示例9: fillSearchBox

def fillSearchBox(fltr, key):
    global channels
    global searchPos
    global main_window
    global list_win

    max_row = list_win.getmaxyx()[0] - 2
    
    filtered = Search.filter_out(fltr, channels)
    
    if (len(filtered) - 1) < max_row:
        max_row = len(filtered) + 1

    if key == 0 and searchPos >= 2:
        searchPos -= 1
    if key == 1 and searchPos < max_row:
        searchPos += 1

    if searchPos > max_row - 1:
        searchPos = max_row - 1

    clearListWin(Strings.search_bx)

    for i in range(1, max_row):
        channel = filtered[i - 1]
        outstr = getRowText(channel)

        if (i == searchPos):
            list_win.addstr(i, 1, outstr, curses.A_REVERSE)
        else:
            list_win.addstr(i, 1, outstr)

    list_win.refresh()
开发者ID:jaydenmilne,项目名称:SetTopPi,代码行数:33,代码来源:ChannelBox.py

示例10: findInFiles

 def findInFiles(self):
     names = []
     pattern = self.findTxt.GetValue()
     bRecursive = self.chkRecursiveSearch.GetValue()
     file_filter = string.split(self.cmbFileFilter.GetValue(), ';')
     folder = [self.cmbFolder.GetValue()]
     self.engine.addFolder(folder[0])
     self.engine.addSuffix(self.cmbFileFilter.GetValue())
     dlg = wx.ProgressDialog(_("Building file list from directory '%s'") % (folder[0]),
                    _('Searching...'), 100, self.view,
                     wx.PD_CAN_ABORT | wx.PD_APP_MODAL | wx.PD_AUTO_HIDE)
     try:
         iterDirFiles = Search.listFiles(folder, file_filter, 1, bRecursive)
         iStep = 0
         for sFile in iterDirFiles:
             names.append(sFile)
             if iStep < 100 and not dlg.Update(iStep):
                 #self.view.model.editor.setStatus('Search aborted')
                 break
             iStep = iStep + 1
     finally:
         dlg.Destroy()
     self.engine.findAllInFiles(names, self.view, pattern )
     self.setComboBoxes('findInFiles')
     if self.engine.closeOnFound:
         self.EndModal(wx.ID_OK)
开发者ID:cwt,项目名称:boa-constructor,代码行数:26,代码来源:FindReplaceDlg.py

示例11: datetimesortkey_chapter_number

def datetimesortkey_chapter_number(x):
    """concatenates chapter number with the time.
    pads the chapter number if necessary."""

    #
    # example keys:
    # _________________________081021_165843
    # 01.English00000000000000_081022_154011
    # 01.Hindi0000000000000000_081022_154008
    #

    if x.has_key("chapter_number"):
        chapter = x["chapter_number"]
        chapter = chapter.strip()
        chapter = chapter[:maxChapterDigits]
        # if chapter.isdigit():
        #    chapter = int(chapter)
        #    chapter = ('%(#)0' + str(maxChapterDigits) + 'd') % {'#': chapter}
        # else:
        #    chapter = chapter.ljust(maxChapterDigits, '0')
        chapter = chapter.ljust(maxChapterDigits, "0")
    else:
        chapter = "".ljust(maxChapterDigits, "_")

    db_print("datetimesortkey_chapter_number, chapter: " + chapter, 38)

    timeVal = Search.changed_time_key(x)
    timeStr = timeVal.strftime("%y%m%d_%H%M%S")
    answer = chapter + "_" + timeStr

    db_print("datetimesortkey_chapter_number, answer: " + answer, 41)
    return answer
开发者ID:aniket134,项目名称:XBMC-video-plugins,代码行数:32,代码来源:ryw.py

示例12: OnSearch

	def OnSearch(self, event):
		keyword = self.search.GetValue()
		if keyword:
			func = lambda data: Search.match(keyword, data)
			self.tree.HighlightTree(func)
		else:
			self.tree.UnHighlightTree()
开发者ID:iambus,项目名称:PyLoad,代码行数:7,代码来源:SpecialsPanel.py

示例13: drawBody

 def drawBody(self, container):
     menu = HorizontalPanel(ID="aur-menu-int")
     search_cont = SimplePanel(StyleName="aur-content-boundary")
     search = VerticalPanel(ID="aur-search")
     footer = VerticalPanel(ID="aur-footer", Width="100%", HorizontalAlignment="center")
     search_cont.add(search)
     container.add(menu)
     container.add(search_cont)
     container.add(self.content)
     container.add(footer)
     container.setCellHeight(menu, "1px")
     container.setCellHeight(footer, "1px")
     container.setCellHorizontalAlignment(footer, "center")
     self.drawInternalMenu(menu)
     Search.draw(search)
     self.drawFooter(footer)
开发者ID:anthonyrisinger,项目名称:aur-pyjs,代码行数:16,代码来源:Aur.py

示例14: post

    def post(self):
        """
        This receives a Query Object and performs a Search based on information from that Query.

        It then compares the results to the search_date and if they are deemed fresh, stores them.
        """
        
        new_search = Search()
        f = formatDatetime()

        q = db.get(self.request.get('key'))
        results = new_search.getResults(q.term, q.min, q.max, q.city)
        
        # Pull fresh listings from query, if they exist
        if q.fresh:
            fresh = q.fresh
        else: 
            fresh = FreshEntries()
            fresh.entries = [] # Store fresh listings here

        search_date = q.search_date
        latest_entry_time = search_date

        # Compare each entry datetime to the saved datetime
        for e in results:
            # Extract and format times from feed
            f_entry_time = f.craigslist_to_datetime(e.date)

            # Compute elapsed time since last search and this listing
            difference = f_entry_time - search_date

            # If entry is after the saved time, flag it as fresh
            if f_entry_time > search_date:

                # Check and see if this is the chronologically latest listing
                if f.craigslist_to_datetime(e.date) > latest_entry_time:
                    latest_entry_time = f.craigslist_to_datetime(e.date)

                entry = Entry(date = e.date, title = e.title, link = e.link)
                db.put(entry)
                fresh.entries.append(entry.key())
        db.put(fresh)

        # put back query with new search_date and new fresh listings
        q.search_date = latest_entry_time
        q.fresh = fresh
        db.put(q)
开发者ID:rcbm,项目名称:thriftfish,代码行数:47,代码来源:Fetch.py

示例15: main

def main(argv):
    """
    main(argv)
    The entry point of the application
    The input format should be: <API key> <infobox/question> <query>
    """
    # API key
    if argv[0] == 'test':
        # Use the default key
        api_key = 'AIzaSyBgfj3L8cqcu6OEd21JkQcHhBQJA6jUOXo'
    else:
        api_key = argv[0]

    # Source: normal, file, or interact
    if argv[1] == 'normal' or argv[1] == 'file' or argv[1] == 'interact':
        source = argv[1]
    else:
        print 'Source should be \"normal\", \"file\", or \"interact\"'
        return

    # Mode: infobox or question
    if source != 'interact':
        if argv[2] == 'infobox' or argv[2] == 'question':
            mode = argv[2]
        else:
            print 'Type should be either \"infobox\" or \"question\"'
            return

    # Get the search engine object with the given API key
    se = Search.get_engine(api_key)

    if source == 'normal':
        query = ' '.join(argv[3:])
        if mode == 'question':
            question(se, query)
        else:
            infobox(se, query)
    elif source == 'file':
        qfile = open(argv[3], 'r')
        for line in qfile:
            if line.endswith('\n'):
                line = line[0:-1]
            if mode == 'question':
                question(se, line)
            else:
                infobox(se, line)
    else:   # Interact
        query = ''
        while True:
            try:
                query = raw_input('Anything curious? ')
                print 'Searching...'
                if query.endswith('?'):
                    question(se, query)
                else:
                    infobox(se, query)
            except KeyboardInterrupt:
                print 'Bye~'
                break
开发者ID:jilikuang,项目名称:Structured_Information_Retrieval,代码行数:59,代码来源:main.py


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