本文整理汇总了Python中Search.buildMangaReplyWithAuthor方法的典型用法代码示例。如果您正苦于以下问题:Python Search.buildMangaReplyWithAuthor方法的具体用法?Python Search.buildMangaReplyWithAuthor怎么用?Python Search.buildMangaReplyWithAuthor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Search
的用法示例。
在下文中一共展示了Search.buildMangaReplyWithAuthor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_comment
# 需要导入模块: import Search [as 别名]
# 或者: from Search import buildMangaReplyWithAuthor [as 别名]
def process_comment(comment, is_edit=False):
#Anime/Manga requests that are found go into separate arrays
animeArray = []
mangaArray = []
lnArray = []
#ignores all "code" markup (i.e. anything between backticks)
comment.body = re.sub(r"\`(?s)(.*?)\`", "", comment.body)
#This checks for requests. First up we check all known tags for the !stats request
if re.search('({!stats.*?}|{{!stats.*?}}|<!stats.*?>|<<!stats.*?>>)', comment.body, re.S) is not None:
username = re.search('[uU]\/([A-Za-z0-9_-]+?)(>|}|$)', comment.body, re.S)
subreddit = re.search('[rR]\/([A-Za-z0-9_]+?)(>|}|$)', comment.body, re.S)
if username:
commentReply = CommentBuilder.buildStatsComment(username=username.group(1))
elif subreddit:
commentReply = CommentBuilder.buildStatsComment(subreddit=subreddit.group(1))
else:
commentReply = CommentBuilder.buildStatsComment()
else:
#The basic algorithm here is:
#If it's an expanded request, build a reply using the data in the braces, clear the arrays, add the reply to the relevant array and ignore everything else.
#If it's a normal request, build a reply using the data in the braces, add the reply to the relevant array.
#Counts the number of expanded results vs total results. If it's not just a single expanded result, they all get turned into normal requests.
numOfRequest = 0
numOfExpandedRequest = 0
forceNormal = False
for match in re.finditer("\{{2}([^}]*)\}{2}|\<{2}([^>]*)\>{2}", comment.body, re.S):
numOfRequest += 1
numOfExpandedRequest += 1
for match in re.finditer("(?<=(?<!\{)\{)([^\{\}]*)(?=\}(?!\}))|(?<=(?<!\<)\<)([^\<\>]*)(?=\>(?!\>))", comment.body, re.S):
numOfRequest += 1
if (numOfExpandedRequest >= 1) and (numOfRequest > 1):
forceNormal = True
#Expanded Anime
for match in re.finditer("\{{2}([^}]*)\}{2}", comment.body, re.S):
reply = ''
if (forceNormal) or (str(comment.subreddit).lower() in disableexpanded):
reply = Search.buildAnimeReply(match.group(1), False, comment)
else:
reply = Search.buildAnimeReply(match.group(1), True, comment)
if (reply is not None):
animeArray.append(reply)
#Normal Anime
for match in re.finditer("(?<=(?<!\{)\{)([^\{\}]*)(?=\}(?!\}))", comment.body, re.S):
reply = Search.buildAnimeReply(match.group(1), False, comment)
if (reply is not None):
animeArray.append(reply)
#Expanded Manga
#NORMAL EXPANDED
for match in re.finditer("\<{2}([^>]*)\>{2}(?!(:|\>))", comment.body, re.S):
reply = ''
if (forceNormal) or (str(comment.subreddit).lower() in disableexpanded):
reply = Search.buildMangaReply(match.group(1), False, comment)
else:
reply = Search.buildMangaReply(match.group(1), True, comment)
if (reply is not None):
mangaArray.append(reply)
#AUTHOR SEARCH EXPANDED
for match in re.finditer("\<{2}([^>]*)\>{2}:\(([^)]+)\)", comment.body, re.S):
reply = ''
if (forceNormal) or (str(comment.subreddit).lower() in disableexpanded):
reply = Search.buildMangaReplyWithAuthor(match.group(1), match.group(2), False, comment)
else:
reply = Search.buildMangaReplyWithAuthor(match.group(1), match.group(2), True, comment)
if (reply is not None):
mangaArray.append(reply)
#Normal Manga
#NORMAL
for match in re.finditer("(?<=(?<!\<)\<)([^\<\>]+)\>(?!(:|\>))", comment.body, re.S):
reply = Search.buildMangaReply(match.group(1), False, comment)
if (reply is not None):
mangaArray.append(reply)
#AUTHOR SEARCH
for match in re.finditer("(?<=(?<!\<)\<)([^\<\>]*)\>:\(([^)]+)\)", comment.body, re.S):
reply = Search.buildMangaReplyWithAuthor(match.group(1), match.group(2), False, comment)
if (reply is not None):
mangaArray.append(reply)
#.........这里部分代码省略.........