本文整理汇总了Python中models.comment.Comment.chunk方法的典型用法代码示例。如果您正苦于以下问题:Python Comment.chunk方法的具体用法?Python Comment.chunk怎么用?Python Comment.chunk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.comment.Comment
的用法示例。
在下文中一共展示了Comment.chunk方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: print
# 需要导入模块: from models.comment import Comment [as 别名]
# 或者: from models.comment.Comment import chunk [as 别名]
print('Connection to reddit failed. Either reddit is down at the moment, or something in the config is incorrect.',sys.exc_info()[0])
logger.critical('Connection to reddit failed. Either reddit is down at the moment, or something in the config is incorrect.',sys.exc_info()[0])
exit()
timeToWait = 30
catechismResponse = objects.Response(catechism, 'http://www.usccb.org/beliefs-and-teachings/what-we-believe/catechism/catechism-of-the-catholic-church/epub/OEBPS/', configuration)
baltimoreResponse = objects.BaltimoreResponse(baltimore, 'http://www.baltimore-catechism.com', configuration)
canonResponse = objects.CanonResponse(canon, 'http://www.vatican.va/archive/ENG1104/', configuration)
girmResponse = objects.GIRMResponse(girm, 'http://www.usccb.org/prayer-and-worship/the-mass/general-instruction-of-the-roman-missal/', configuration)
processedComments = list()
logger.info('Beginning to scan comments...')
# This loop runs every 30 seconds.
while True:
processedComments.clear()
for comments in Comment.chunk(1000):
for comment in comments:
processedComments.append(comment.commentId)
subredditFilter = "isEnabled = 1"
if args['sandbox']:
subredditFilter += " and isSandbox = 1"
subredditsList = list()
for subreddit in Subreddit.where_raw(subredditFilter).get():
subredditsList.append(subreddit.subreddit)
subredditQuery = "+".join(subredditsList)
subreddit = r.subreddit(subredditQuery)
try:
for comment in subreddit.stream.comments():
if comment and comment.author.name != configuration.username and comment.id not in processedComments:
logger.info("Processing comment %s by user %s" % (comment.id, comment.author.name))