本文整理汇总了Python中query.Query.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Query.debug方法的具体用法?Python Query.debug怎么用?Python Query.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类query.Query
的用法示例。
在下文中一共展示了Query.debug方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_to_and_from_dict
# 需要导入模块: from query import Query [as 别名]
# 或者: from query.Query import debug [as 别名]
def test_to_and_from_dict(self):
x = Query("a", 10, True, "blahblah", ["bar"])
x.debug = True
y = x.as_dict()
z = Query.from_dict(y)
self.assertEquals(x.text, z.text)
self.assertEquals(x.max_hits, z.max_hits)
self.assertEquals(x.exact_match, z.exact_match)
self.assertEquals(x.current_filename, z.current_filename)
self.assertEquals(x.open_filenames, z.open_filenames)
self.assertEquals(x.debug, z.debug)
示例2: CMDrawsearch
# 需要导入模块: from query import Query [as 别名]
# 或者: from query.Query import debug [as 别名]
def CMDrawsearch(parser):
"""Prints the raw database's results for <query>"""
parser.add_option('--show-rank', '-r', dest='show_rank', action='store_true', help='Show the ranking of results')
parser.add_option('--current-filename', dest='current_filename', action='store', default=None, help="Hints quickopen about the current buffer to improve search relevance.")
parser.add_option('--open-filenames', dest='open_filenames', action='store', default=[], help="Hints quickopen about the filenames currently open to improve search relevance.")
parser.add_option('--debug', dest='debug', action='store_true', default=False, help='Debug the query instead of executing it')
(options, args) = parser.parse_args()
db = open_db(options)
if len(args) != 1:
parser.error('Expected: <query>')
if not db.has_index:
print "Database is not fully indexed. Wait a bit or try quickopen status"
return 255
search_args = {}
if options.current_filename:
search_args["current_filename"] = options.current_filename
if options.open_filenames:
search_args["open_filenames"] = split_open_filenames(options.open_filenames)
q = Query(args[0],**search_args)
if options.debug:
q.debug = True
res = db.search(q)
if options.debug:
import pprint
print pprint.pprint(res.as_dict())
elif options.show_rank:
combined = res.hits
print "\n".join(["%i,%s" % (c[1],c[0]) for c in combined])
else:
print "\n".join([x for x in res.filenames])
if len(res.filenames) > 0:
return 0
return 255