本文整理汇总了Python中search.Search.search方法的典型用法代码示例。如果您正苦于以下问题:Python Search.search方法的具体用法?Python Search.search怎么用?Python Search.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类search.Search
的用法示例。
在下文中一共展示了Search.search方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GET
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def GET(self):
logging.debug(self.input)
userName = auth.uuap_sso()
products = auth.getProcByName(userName)
if products==None or len(products)==0:
web.config.session.kill()
return render.forbidden(userName)
if self.input == None or len(self.input) == 0:
return render.manage(userName, products, web.ctx.homedomain)
#更新树形菜单
if self.input['oper'] == 'updatelist':
#检查文件夹是否存在,不存在则创建
dirPath = 'data/updateflag'
product = self.input['product']
updateflag = '%s/%s' % (dirPath,product)
if not os.path.exists(dirPath):
os.makedirs(dirPath)
#创建更新标志文件以触发updatelist.sh的更新任务
f = open(updateflag, 'w')
f.close()
while os.path.exists(updateflag):
time.sleep(0.1)
return json.dumps({'code':200,'txt':u'更新成功'})
elif self.input['oper'] == 'search':
s = Search(self.input)
return s.search()
示例2: get_search_results
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def get_search_results():
try:
search_text = request.json['search-text']
s = Search( search_text )
results = s.search()
return render_template( 'search_results.html', results=results), 200
except ValueError, e:
return render_template( 'search_error.html', errortext=str(e))
示例3: test_search
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def test_search(self):
# Create search interface and reset the index
s = Search()
s.reset_index()
# Create a couple of objects and add them to the index
testa = models.SearchTest()
testa.title = "Hello World"
testa.save()
s.add(testa)
testb = models.SearchTest()
testb.title = "Hello"
testb.save()
s.add(testb)
testc = models.SearchTestChild()
testc.title = "Hello"
testc.save()
s.add(testc)
# Refresh index
s.refresh_index()
# Ordinary search
results = s.search("Hello", models.SearchTest)
self.assertEqual(len(results), 3)
# Ordinary search on "World"
results = s.search("World", models.SearchTest)
self.assertEqual(len(results), 1)
# Searcher search
results = models.SearchTest.title_search("Hello")
self.assertEqual(len(results), 3)
# Ordinary search on child
results = s.search("Hello", models.SearchTestChild)
self.assertEqual(len(results), 1)
# Searcher search on child
results = models.SearchTestChild.title_search("Hello")
self.assertEqual(len(results), 1)
示例4: TestSequenceFunctions
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
self.max_distance = 150
self.search = Search(self.max_distance)
self.text = []
self.query = []
text = """This pizza makes my mouth water just thinking about it. The regular pie is pretty dang good, but of course their deep dish is where it's at. Tried it since it was on the big eats list and have been back time and again for more. The little star was the one on the list, and although pretty good, i love the classic. The atmosphere is great, good wine, decent service and even if there's a really long wait it goes by pretty quick if you hang out at the bar. they've got the ordering situation down so you don't have to wait at the table for a long time. Once you're seated your food comes right out.
This pizza makes my mouth water just thinking about it. The regular pie is pretty dang good, but of course their deep dish is where it's at. Tried it since it was on the big eats list and have been back time and again for more. The little star was the one on the list, and although pretty good, i love the classic. The atmosphere is great, good wine, decent service and even if there's a really long wait it goes by pretty quick if you hang out at the bar. they've got the ordering situation down so you don't have to wait at the table for a long time. Once you're seated your food comes right out.
People requiring very advanced shell programming skills are recommended to learn python instead.
Each volume in the pocketfuls series is picked by a different python and includes their best visual and verbal gags.
Python script by default expects your data to be stored in a certain form.
The next find of note was an african rock python which was at least four meters long.
I want to make a habit of using python now.
Python language interpreter.
He told me he had killed snakes before - including a measly 13ft python - but had never taken
This pizza makes my mouth water just thinking about it. The regular pie is pretty dang good, but of course their deep dish is where it's at. Tried it since it was on the big eats list and have been back time and again for more. The little star was the one on the list, and although pretty good, i love the classic. The atmosphere is great, good wine, decent service and even if there's a really long wait it goes by pretty quick if you hang out at the bar. they've got the ordering situation down so you don't have to wait at the table for a long time. Once you're seated your food comes right out.
People requiring very advanced shell programming skills are recommended to learn python instead.
Each volume in the pocketfuls series is picked by a different python and includes their best visual and verbal gags.
Python script by default expects your data to be stored in a certain form.
The next find of note was an african rock python which was at least four meters long.
I want to make a habit of using python now.
Python language interpreter.
He told me he had killed snakes before - including a measly 13ft python - but had never taken
This pizza makes my mouth water just thinking about it. The regular pie is pretty dang good, but of course their deep dish is where it's at. Tried it since it was on the big eats list and have been back time and again for more. The little star was the one on the list, and although pretty good, i love the classic. The atmosphere is great, good wine, decent service and even if there's a really long wait it goes by pretty quick if you hang out at the bar. they've got the ordering situation down so you don't have to wait at the table for a long time. Once you're seated your food comes right out.
"""
self.text.append(text)
text = "This pizza makes my mouth water just thinking about it. The r egular pie is pretty dang good, but of course their deep dish is where it's at. Tried it since it was on the big eats list and have been back time and again for more. The little star was the one on the list, and although pretty good, i love the classic. The atmosphere is great, good wine, decent service and even if there's a really long wait it goes by pretty quick if you hang out at the bar. they've got the ordering situation down so you don't have to wait at the table for a long time. Once you're seated your food comes right out."
self.text.append(text)
text = "hello pi"
self.text.append(text)
self.query.append("deep dish pizza")
self.query.append("pizza")
pass
def testsearch(self):
print 'Test text'.center(50, '-')
print self.text[1]
print '-'.center(50, '-')
print 'max_distance = %s' % self.max_distance
print 'a search query -> %s' % self.query
print 'Results'.center(50, '-')
parts = self.search.search(self.text[2], self.query[1])
for part in parts:
print 'count keywords - %s' % part['count-keywords']
print part['text']
print '-'.center(50, '-')
self.assertTrue(True)
def testdoc(self):
print help(Search)
def tearDown(self):
del self.search
示例5: run
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def run(self):
search = Search(DATABASE_FILE_NAME)
# Search!
result_list = search.search(self.term)
# Create an HTML file and open it in the default browser
name = self.generate_html_file(result_list)
webbrowser.open('file://' + name)
# Re-enable the search button
self.app.button.config(text='Search', state=ACTIVE)
示例6: POST
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def POST(self):
x = web.input(myfile={})
print x['myfile'].filename
gm=Global_Mod()
gm.img = cv2.imdecode(numpy.fromstring(x['myfile'].file.read(), numpy.uint8), cv2.IMREAD_UNCHANGED)
resultslist=Search.search(gm.img)
for row in resultslist:
temp=list(row)
gm.results.append(temp[1].replace('\\','/'))
print gm.results
return render.base(view.imgresult(gm.img,gm.results))
示例7: search
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def search():
#rand = random.randrange(0, db.session.query(Tweet).count())
#tweet = db.session.query(Tweet)[rand]
username = "wa3l"
query = "south" #get it from the index page text field
search_obj = Search(username,query)
search_result = search_obj.search()
# ??? how to send a list using jsonfy
return jsonify(
id=tweet.tweet_id,
text=tweet.text,
link=tweet.link,
user_id=tweet.user_id,
screen_name=tweet.screen_name,
retweet_count=tweet.retweet_count,
)
示例8: search
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def search():
query = request.args['query']
fields = request.args.get('fields')
if fields == 'None':
fields = None
directories = []
search = Search(app.config["INDEX_DIR"])
if not query:
tag_cloud = search.get_tags()
parsed_query = ""
result = []
directories=get_directories()
else:
parsed_query, result, tag_cloud = search.search(query.split(), fields=[fields])
store_search(query, fields)
total = search.get_document_total_count()
return render_template('search.html', entries=result, query=query, parsed_query=parsed_query, fields=fields, tag_cloud=tag_cloud, last_searches=get_last_searches(), directories=directories, total=total)
示例9: calculate
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def calculate(*args):
try:
text = data_entry.get("1.0", "end")
arr = text.split()
if len(arr) <3:
raise Exception("Input not correct, to few tuples")
for i in range(len(arr)):
#TODO: Not to happy about space after commas. (10, 10)
arr[i] = eval(arr[i])
dim = arr.pop(0)
start = arr.pop(0)
end = arr.pop(0)
except ValueError:
pass
s = Search( navigation_map )
state = NavigationState( start, end, dim, arr )
navigation_map.setModel(state)
navigation_map.start()
initalNode = NavigationNode( state, start[0], start[1] )
result = s.search( initalNode, SearchMode(v.get()) )
navigation_map.stop()
示例10: main
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def main(args):
"""
Main function - launches the program.
:param args:
The Parser arguments
:type args:
Parser object
:returns:
List
:example:
>>> ["The latitude and longitude values must be valid numbers", 1]
"""
v = VerbosityMixin()
if args:
if 'clip' in args:
bounds = convert_to_float_list(args.clip)
else:
bounds = None
if args.subs == 'process':
verbose = True if args.verbose else False
force_unzip = True if args.force_unzip else False
stored = process_image(args.path, args.bands, verbose, args.pansharpen, args.ndvi, force_unzip,
args.ndvigrey, bounds)
if args.upload:
u = Uploader(args.key, args.secret, args.region)
u.run(args.bucket, get_file(stored), stored)
return ["The output is stored at %s" % stored]
elif args.subs == 'search':
try:
if args.start:
args.start = reformat_date(parse(args.start))
if args.end:
args.end = reformat_date(parse(args.end))
if args.latest > 0:
args.limit = 25
end = datetime.now()
start = end - relativedelta(days=+365)
args.end = end.strftime("%Y-%m-%d")
args.start = start.strftime("%Y-%m-%d")
except (TypeError, ValueError):
return ["Your date format is incorrect. Please try again!", 1]
s = Search()
try:
lat = float(args.lat) if args.lat else None
lon = float(args.lon) if args.lon else None
except ValueError:
return ["The latitude and longitude values must be valid numbers", 1]
address = args.address
if address and (lat and lon):
return ["Cannot specify both address and latitude-longitude"]
result = s.search(paths_rows=args.pathrow,
lat=lat,
lon=lon,
address=address,
limit=args.limit,
start_date=args.start,
end_date=args.end,
cloud_max=args.cloud)
if result['status'] == 'SUCCESS':
if args.json:
return json.dumps(result)
if args.latest > 0:
datelist = []
for i in range(0, result['total_returned']):
datelist.append((result['results'][i]['date'], result['results'][i]))
datelist.sort(key=lambda tup: tup[0], reverse=True)
datelist = datelist[:args.latest]
result['results'] = []
for i in range(0, len(datelist)):
result['results'].append(datelist[i][1])
result['total_returned'] = len(datelist)
else:
v.output('%s items were found' % result['total'], normal=True, arrow=True)
if result['total'] > 100:
return ['Over 100 results. Please narrow your search', 1]
else:
v.output(json.dumps(result, sort_keys=True, indent=4), normal=True, color='green')
return ['Search completed!']
#.........这里部分代码省略.........
示例11: search
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def search(self, searchString, expected):
self.startCoverage("search")
s = Search(self)
result = s.search(searchString, expected)
self.endCoverage()
return result
示例12: main
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def main(args):
"""
Main function - launches the program.
:param args:
The Parser arguments
:type args:
Parser object
:returns:
List
:example:
>>> ["The latitude and longitude values must be valid numbers", 1]
"""
v = VerbosityMixin()
if args:
if args.subs == 'process':
verbose = True if args.verbose else False
force_unzip = True if args.force_unzip else False
stored = process_image(args.path, args.bands, verbose, args.pansharpen, args.ndvi, force_unzip, args.ndvi1)
if args.upload:
u = Uploader(args.key, args.secret, args.region)
u.run(args.bucket, get_file(stored), stored)
return ["The output is stored at %s" % stored]
elif args.subs == 'search':
try:
if args.start:
args.start = reformat_date(parse(args.start))
if args.end:
args.end = reformat_date(parse(args.end))
except (TypeError, ValueError):
return ["You date format is incorrect. Please try again!", 1]
s = Search()
try:
lat = float(args.lat) if args.lat else None
lon = float(args.lon) if args.lon else None
except ValueError:
return ["The latitude and longitude values must be valid numbers", 1]
result = s.search(paths_rows=args.pathrow,
lat=lat,
lon=lon,
limit=args.limit,
start_date=args.start,
end_date=args.end,
cloud_max=args.cloud)
if result['status'] == 'SUCCESS':
v.output('%s items were found' % result['total'], normal=True, arrow=True)
if result['total'] > 100:
return ['Over 100 results. Please narrow your search', 1]
else:
v.output(json.dumps(result, sort_keys=True, indent=4), normal=True, color='green')
return ['Search completed!']
elif result['status'] == 'error':
return [result['message'], 1]
elif args.subs == 'download':
d = Downloader(download_dir=args.dest)
try:
bands = convert_to_integer_list(args.bands)
if args.pansharpen:
bands.append(8)
if args.ndvi:
bands = [4, 5]
downloaded = d.download(args.scenes, bands)
if args.process:
force_unzip = True if args.force_unzip else False
for scene, src in downloaded.iteritems():
if args.dest:
path = join(args.dest, scene)
else:
path = join(settings.DOWNLOAD_DIR, scene)
# Keep using Google if the image is before 2015
if src == 'google':
path = path + '.tar.bz'
stored = process_image(path, args.bands, False, args.pansharpen, args.ndvi, force_unzip)
if args.upload:
try:
u = Uploader(args.key, args.secret, args.region)
except NoAuthHandlerFound:
return ["Could not authenticate with AWS", 1]
except URLError:
return ["Connection timeout. Probably the region parameter is incorrect", 1]
u.run(args.bucket, get_file(stored), stored)
#.........这里部分代码省略.........
示例13: API
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
from auth import API
import tweepy
import datetime
import json
new_api = API()
api = new_api.authenticate()
from search import Search
search = Search("#tealover", 4)
json = search.search()
print json
示例14: vars
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
from descriptor import Descriptor
from search import Search
import glob
import cv2
import argparse
argument_parser = argparse.ArgumentParser()
argument_parser.add_argument('-i','--index', required = True,
help = 'Path to save computed index')
argument_parser.add_argument('-q','--query', required = True,
help = 'Path to query image')
argument_parser.add_argument('-d','--dataset', required = True,
help = 'Path to result')
args = vars(argument_parser.parse_args())
color_descriptor = Descriptor((8, 12, 3))
query_image = cv2.imread(args['query'])
query_feature = color_descriptor.describe(query_image)
searcher = Search(args['index'])
feature_result = searcher.search(query_feature)
cv2.imshow('Query Image', query_image)
for score, image_name in feature_result:
result = cv2.imread(args['dataset'] + '/' + image_name)
cv2.imshow('Best Matching', result)
cv2.waitKey(0)
示例15: main
# 需要导入模块: from search import Search [as 别名]
# 或者: from search.Search import search [as 别名]
def main(args):
"""
Main function - launches the program
"""
v = VerbosityMixin()
if args:
if args.subs == 'process':
verbose = True if args.verbose else False
try:
bands = convert_to_integer_list(args.bands)
p = Process(args.path, bands=bands, verbose=verbose)
except IOError:
exit("Zip file corrupted", 1)
except FileDoesNotExist as e:
exit(e.message, 1)
stored = p.run(args.pansharpen)
exit("The output is stored at %s" % stored)
elif args.subs == 'search':
try:
if args.start:
args.start = reformat_date(parse(args.start))
if args.end:
args.end = reformat_date(parse(args.end))
except (TypeError, ValueError):
exit("You date format is incorrect. Please try again!", 1)
s = Search()
try:
lat = float(args.lat) if args.lat else None
lon = float(args.lon) if args.lon else None
except ValueError:
exit("The latitude and longitude values must be valid numbers", 1)
result = s.search(paths_rows=args.pathrow,
lat=lat,
lon=lon,
limit=args.limit,
start_date=args.start,
end_date=args.end,
cloud_max=args.cloud)
if result['status'] == 'SUCCESS':
v.output('%s items were found' % result['total'], normal=True, arrow=True)
if result['total'] > 100:
exit('Over 100 results. Please narrow your search', 1)
else:
v.output(json.dumps(result, sort_keys=True, indent=4), normal=True, color='green')
exit('Search completed!')
elif result['status'] == 'error':
exit(result['message'], 1)
elif args.subs == 'download':
d = Downloader(download_dir=args.dest)
try:
if d.download(args.scenes, convert_to_integer_list(args.bands)):
exit('Download Completed', 0)
except IncorrectSceneId:
exit('The SceneID provided was incorrect', 1)