Skip to content

Commit

Permalink
use raw string
Browse files Browse the repository at this point in the history
  • Loading branch information
datawhores committed Aug 22, 2024
1 parent f9d3d5b commit c73fa2c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions ofscraper/filters/media/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,12 @@ def post_text_filter(media):
for ele in userfilter:
if not ele.islower():
curr = list(
filter(lambda x: re.search(ele, x.text or "") is not None, curr)
filter(lambda x: re.search(ele, r"""{}""".format(x.text or "")) is not None, curr)
)
else:
curr = list(
filter(
lambda x: re.search(ele, x.text or "", re.IGNORECASE) is not None,
lambda x: re.search(ele, r"""{}""".format(x.text or ""), re.IGNORECASE) is not None,
curr,
)
)
Expand All @@ -284,11 +284,11 @@ def post_neg_text_filter(media):
curr = media
for ele in userfilter:
if not ele.islower():
curr = list(filter(lambda x: re.search(ele, x.text or "") is None, curr))
curr = list(filter(lambda x: re.search(ele, r"""{}""".format(x.text or "")) is None, curr))
else:
curr = list(
filter(
lambda x: re.search(ele, x.text or "", re.IGNORECASE) is None,
lambda x: re.search(ele, r"""{}""".format(x.text or ""), re.IGNORECASE) is None,
curr,
)
)
Expand Down
14 changes: 12 additions & 2 deletions ofscraper/utils/args/parse/arguments/content.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,12 @@
filter_option = click.option(
"-ft",
"--filter",
help="Filter posts by regex (case-sensitive if uppercase characters included)",
help="""
\b
Filter posts by regex
(case-sensitive if uppercase characters included)
uses raw python string
""",
default=[".*"],
required=False,
callback=StringTupleList,
Expand All @@ -108,7 +113,12 @@
neg_filter_option = click.option(
"-nf",
"--neg-filter",
help="Filter posts to exclude those matching regex (case-styensitive if uppercase characters included)",
help="""
\b
Filter posts to exclude those matching regex
(case-styensitive if uppercase characters included)
uses raw python string
""",
default=[],
required=False,
type=str,
Expand Down

0 comments on commit c73fa2c

Please sign in to comment.