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


Python Score.all方法代码示例

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


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

示例1: delete_duplicates

# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import all [as 别名]
	def delete_duplicates( self, control, location ):
		scores = Score.all().filter( "control =", control )
		
		if not location in ( config.LOCATION_WORLD, config.LOCATION_WEEK ):
			scores = scores.filter( "location =", location )
		
		elif location == config.LOCATION_WEEK:
			scores = scores.filter( "new_week =", True )
		elif location != config.LOCATION_WORLD:
			logging.error( "CronJob.delete_duplicates: Got an invalid " \
				+ "location \"%s\".", location )
			return
		
		fetched = scores.order( "-points" ).fetch( config.TOP_LIST_LENGTH )
		fetched = sorted( fetched, key=lambda score: score.date )
		
		to_remove = []
		i = 0
		while i < len( fetched ):
			scorei = fetched[i]
			j = i+1
			while j < len( fetched ):
				scorej = fetched[j]
				if not scorei is scorej and scorei.equals( scorej ) \
						and not scorej in to_remove:
					to_remove.append( scorej )
				j += 1
			i += 1
		
		have = [ score.to_dict() for score in fetched ]
		logging.info( "Location: \"%s\" Have %d scores: %s", location,
			len( have ), have )
		
		would = [ score.to_dict() for score in to_remove ]
		logging.info( "Location: \"%s\"Would remove %d scores: %s", location,
			len( would ), would )
		
		count1 = 0
		for score in to_remove:
			if score in fetched:
				count1 += 1
		
		count2 = 0
		for score in fetched:
			if score in to_remove:
				count2 += 1
		
		logging.info( "count1: %d, count2: %d", count1, count2 )
		
		try:
			db.delete( to_remove )
			self.response.out.write(
				"<br />all entities deleted successfully." )
		except Exception, msg:
			self.response.out.write( "<br />Got exception: '%s'." % msg \
				+ "<br />Some or all deletes might have failed." )
开发者ID:baskus,项目名称:prendo,代码行数:58,代码来源:cronjob.py

示例2: clean_country

# 需要导入模块: from score import Score [as 别名]
# 或者: from score.Score import all [as 别名]
	def clean_country( self, control, location, lowest_score ):
		scores = Score.all() \
			.filter( "control =", control ) \
			.filter( "location =", location ) \
			.filter( "points <", lowest_score ) \
			.filter( "new_week =", False ) \
			.fetch( 400 )
		
		high = 0
		for s in scores:
			if s.points > high:
				high = s.points
		
		try:
			db.delete( scores )
		except Exception, msg:
			logging.error( "Got exception: '%s'. Some or all deletes might " \
				+ "have failed.", msg )
开发者ID:baskus,项目名称:prendo,代码行数:20,代码来源:cronjob.py


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