本文整理汇总了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
示例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()
示例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)
示例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])
示例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
示例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)
示例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()
示例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")
示例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()
示例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)
示例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
示例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()
示例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)
示例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)
示例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