config: remove filtering by url pattern, tags are enough
This commit is contained in:
parent
7a89938d4f
commit
e73b68a131
|
@ -44,18 +44,6 @@ _LOGGER = getLogger(__file__)
|
|||
)
|
||||
@option("--no-cache", type=bool, help="Disable caching", count=True)
|
||||
@option("-u", "--update-index", type=bool, help="Reload cached theme index", count=True)
|
||||
@option(
|
||||
"--include-urls",
|
||||
type=str,
|
||||
multiple=True,
|
||||
help="Take into account only urls matching these patterns",
|
||||
)
|
||||
@option(
|
||||
"--exclude-urls",
|
||||
type=str,
|
||||
multiple=True,
|
||||
help="Ignore urls matching this pattern",
|
||||
)
|
||||
@option(
|
||||
"-i",
|
||||
"--include-tags",
|
||||
|
@ -77,8 +65,6 @@ async def main(
|
|||
source: str,
|
||||
no_cache: bool,
|
||||
update_index: bool,
|
||||
include_urls: list[str],
|
||||
exclude_urls: list[str],
|
||||
include_tags: list[str],
|
||||
exclude_tags: list[str],
|
||||
) -> None:
|
||||
|
@ -89,8 +75,6 @@ async def main(
|
|||
update_index,
|
||||
source,
|
||||
not no_cache,
|
||||
include_urls,
|
||||
exclude_urls,
|
||||
include_tags,
|
||||
exclude_tags,
|
||||
)
|
||||
|
|
|
@ -25,8 +25,6 @@ class Config:
|
|||
self,
|
||||
source_name: Optional[str],
|
||||
use_cache: bool,
|
||||
include_urls: list[str],
|
||||
exclude_urls: list[str],
|
||||
include_tags: list[str],
|
||||
exclude_tags: list[str],
|
||||
):
|
||||
|
@ -40,8 +38,6 @@ class Config:
|
|||
self._source_name = source_name if source_name else REMOTE_SOURCE_NAME
|
||||
|
||||
self._filter = _Filter(
|
||||
include_urls,
|
||||
exclude_urls,
|
||||
include_tags,
|
||||
exclude_tags,
|
||||
)
|
||||
|
@ -152,25 +148,13 @@ class Config:
|
|||
class _Filter:
|
||||
def __init__(
|
||||
self,
|
||||
include_urls: list[str],
|
||||
exclude_urls: list[str],
|
||||
include_tags: list[str],
|
||||
exclude_tags: list[str],
|
||||
):
|
||||
self._include_urls = [re_compile(it) for it in include_urls]
|
||||
self._exclude_urls = [re_compile(it) for it in exclude_urls]
|
||||
self._include_tags = set(include_tags)
|
||||
self._exclude_tags = set(exclude_tags)
|
||||
|
||||
def __call__(self, url: str, tags: set[str]) -> bool:
|
||||
if self._include_urls:
|
||||
if all(not it.match(url) for it in self._include_urls):
|
||||
return False
|
||||
|
||||
if self._exclude_urls:
|
||||
if any(it.match(url) for it in self._exclude_urls):
|
||||
return False
|
||||
|
||||
if self._include_tags and not self._include_tags & tags:
|
||||
return False
|
||||
|
||||
|
|
Loading…
Reference in New Issue