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


Python DB.insert_scan方法代码示例

本文整理汇总了Python中DB.insert_scan方法的典型用法代码示例。如果您正苦于以下问题:Python DB.insert_scan方法的具体用法?Python DB.insert_scan怎么用?Python DB.insert_scan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


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

示例1: handleRule

# 需要导入模块: import DB [as 别名]
# 或者: from DB import insert_scan [as 别名]
def handleRule(rule):
	ic = ItemCrawler()
	db_avg_cost = DB.get_avg_price(rule.link)
	
	Log("{} for less then {} Chaos".format(rule.name, (PRICE_MULTIPLICATOR*db_avg_cost)),"CURRENT SCAN", "blue", 0)
	
	hits = ic.hits(rule.link)
	
	if not rule.enabled:
		return
	
	isFirst = True
	hitCnt = 0
	hitSum = 0
	for hit in hits:
		
		cost = Crawler.getCostFromEntry(hit)
		ign  = Crawler.getIGNFromEntry(hit)
		(corrupted, item_name) = Crawler.getItemNameFromEntry(hit)
		
		item_print = item_name 
		
		if not item_name:
			item_name = "<NOT FOUND>"
		else:
			if corrupted:
				item_print = Fore.RED + "Corrupted" + Fore.RESET + " " + item_name
				
		chaos_cost = Currency.getChaosValue(cost)
		
		# Solange noch kein Item gefunden wurde ist db_avg_cost = 0 und db_avg_cost * PRICE_IGNORE_MIN ebenfalls. 
		# Das gleiche gilt für PRICE_IGNORE_MAX
		if not db_avg_cost:
			db_avg_cost = chaos_cost
			
		if chaos_cost < db_avg_cost * PRICE_IGNORE_MIN or chaos_cost > db_avg_cost * PRICE_IGNORE_MAX:
			Log("Someone is selling {} ({}) for {} chaos!!".format(item_print, rule.link, chaos_cost), 
				"TROLL ALERT", "red", 0)
			continue
		
		if(hitCnt < MAX_HITS_FOR_AVG):
			hitSum += chaos_cost
			hitCnt += 1
			
		
		# if chaos_cost <= rule.price and isFirst:
		if chaos_cost <= (PRICE_MULTIPLICATOR*db_avg_cost):
			Log("Schnappaaah : ", "INFO", "yellow", 0)
			Log(rule.name, "RULE", None, 1)
			Log(item_print, "ITEM", None, 1)
			Log(rule.link, "LINK", None, 1)
			Log(cost, "COST", None, 1)
			Log(chaos_cost, "CHAOS COST", None, 1)
			Log("@{} Hi, I would like to buy your {} listed for {} in {}\n".format(ign, item_name, cost, LEAGUE), "WHISPER", None, 1)
			
			if rule.alert:
				os.system("start C:\\Users\\Ramon\\workspace\\git\\rockwurst\\testsound.mp3")

			isFirst = False
	if len(hits) > 0:
		hitAvg = hitSum / hitCnt
		Log("took the first {} items with an avarage of {} chaos".format(hitCnt, hitAvg), "SCAN RESULT", "white", 0)
		
		DB.insert_scan(rule.link, hitAvg)
开发者ID:brainlezz,项目名称:rockwurst,代码行数:66,代码来源:Rockwurst.py


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