From e73b68a13154d6c14e6351ede2931ae1c49b1f48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Corentin=20S=C3=A9chet?= Date: Wed, 13 Apr 2022 15:10:16 +0200 Subject: [PATCH] config: remove filtering by url pattern, tags are enough --- frontools/cli.py | 16 ---------------- frontools/config.py | 16 ---------------- 2 files changed, 32 deletions(-) diff --git a/frontools/cli.py b/frontools/cli.py index 18b09d4..f0332d1 100644 --- a/frontools/cli.py +++ b/frontools/cli.py @@ -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, ) diff --git a/frontools/config.py b/frontools/config.py index 7e36aa0..63e19ad 100644 --- a/frontools/config.py +++ b/frontools/config.py @@ -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