Skip to content

Commit

Permalink
Parsing: Line length limit 120.
Browse files Browse the repository at this point in the history
  • Loading branch information
teward committed Jan 17, 2017
1 parent 2cd7c3a commit a892a06
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def get_user_from_url(url):

# noinspection PyBroadException
def fetch_post_url_from_msg_content(content):
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\)(?: \| \[.+\]\(.+\))? \] [\w\s,:\(\)-]+: \[.+]\(((?:http:)?\/\/[\w.]+\/questions\/\d+(?:\/.*)?|(?:http:)?\/\/[\w.]+\/[qa]\/\d+/?)(?:\?smokeypost=true)?\) by \[?.*\]?\(?(?:.*)\)? on `[\w.]+`(?: \(@.+\))?(?: \[.+\]\(.+\))?$"
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\)(?: \| \[.+\]\(.+\))? \] [\w\s,:\(\)-]+: \[.+]\(((?:http:)" \
r"?\/\/[\w.]+\/questions\/\d+(?:\/.*)?|(?:http:)?\/\/[\w.]+\/[qa]\/\d+/?)(?:\?smokeypost=true)?\)" \
r" by \[?.*\]?\(?(?:.*)\)? on `[\w.]+`(?: \(@.+\))?(?: \[.+\]\(.+\))?$"
match = regex.compile(search_regex).search(content)
if match is None:
return None
Expand Down Expand Up @@ -70,7 +72,9 @@ def fetch_post_id_and_site_from_msg_content(content):

# noinspection PyBroadException
def fetch_owner_url_from_msg_content(content):
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\)(?: \| \[.+\]\(.+\))? \] [\w\s,:\(\)-]+: \[.+]\((?:(?:http:)?\/\/[\w.]+\/questions\/\d+(?:\/.*)?|(?:http:)?\/\/[\w.]+\/[qa]\/\d+/?)\) by \[.+\]\((.+)\) on `[\w.]+`(?: \(@.+\))?(?: \[.+\]\(.+\))?$"
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\)(?: \| \[.+\]\(.+\))? \] [\w\s,:\(\)-]+: \[.+]\((?:(?:http:)" \
r"?\/\/[\w.]+\/questions\/\d+(?:\/.*)?|(?:http:)?\/\/[\w.]+\/[qa]\/\d+/?)\) by \[.+\]\((.+)\)" \
r" on `[\w.]+`(?: \(@.+\))?(?: \[.+\]\(.+\))?$"
match = regex.compile(search_regex).search(content)
if match is None:
return None
Expand All @@ -83,7 +87,9 @@ def fetch_owner_url_from_msg_content(content):

# noinspection PyBroadException
def fetch_title_from_msg_content(content):
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\)(?: \| \[.+\]\(.+\))? \] [\w\s,:\(\)-]+: \[(.+)]\((?:(?:http:)?\/\/[\w.]+\/questions\/\d+(?:\/.*)?|(?:http:)?\/\/[\w.]+\/[qa]\/\d+/?)\) by \[?.*\]?\(?.*\)? on `[\w.]+`(?: \(@.+\))?(?: \[.+\]\(.+\))?$"
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\)(?: \| \[.+\]\(.+\))? \] [\w\s,:\(\)-]+: \[(.+)]\((?:(?:http:)" \
r"?\/\/[\w.]+\/questions\/\d+(?:\/.*)?|(?:http:)?\/\/[\w.]+\/[qa]\/\d+/?)\) by \[?.*\]?\(?.*\)?" \
r" on `[\w.]+`(?: \(@.+\))?(?: \[.+\]\(.+\))?$"
match = regex.compile(search_regex).search(content)
if match is None:
return None
Expand All @@ -96,7 +102,8 @@ def fetch_title_from_msg_content(content):

# noinspection PyBroadException
def fetch_user_from_allspam_report(content):
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\) \] All of this user's posts are spam: \[user \d+ on [\w\.]+\]\((//[\w\.]+/users/\d+\D*)\)(?: \[.+\]\(.+\))?$"
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\) \] All of this user's posts are spam: \[user \d+ on " \
r"[\w\.]+\]\((//[\w\.]+/users/\d+\D*)\)(?: \[.+\]\(.+\))?$"
match = regex.compile(search_regex).search(content)
if match is None:
return None
Expand All @@ -109,7 +116,9 @@ def fetch_user_from_allspam_report(content):

# noinspection PyBroadException
def edited_message_after_postgone_command(content):
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\)(?: \| \[.+\]\(.+\))? \] [\w\s,:\(\)-]+: (\[.+]\((?:(?:http:)?\/\/[\w.]+\/questions\/\d+(?:\/.*)?|(?:http:)?\/\/[\w.]+\/[qa]\/\d+/?)\)) by \[?.*\]?\(?.*\)? on `[\w.]+`(?: \(@.+\))?(?: \[.+\]\(.+\))?$"
search_regex = r"^\[ \[SmokeDetector\]\([^)]*\)(?: \| \[.+\]\(.+\))? \] [\w\s,:\(\)-]+: (\[.+]\((?:(?:http:)" \
r"?\/\/[\w.]+\/questions\/\d+(?:\/.*)?|(?:http:)?\/\/[\w.]+\/[qa]\/\d+/?)\)) by \[?.*\]?\(?.*\)?" \
r" on `[\w.]+`(?: \(@.+\))?(?: \[.+\]\(.+\))?$"
match = regex.compile(search_regex).search(content)
if match is None:
return None
Expand Down

0 comments on commit a892a06

Please sign in to comment.