fix: use string in config
This commit is contained in:
parent
8bc88fad18
commit
57cb230d3d
|
@ -140,18 +140,23 @@ class Filter:
|
||||||
def remove_block_titles(self) -> None:
|
def remove_block_titles(self) -> None:
|
||||||
if not self.main_divs:
|
if not self.main_divs:
|
||||||
return
|
return
|
||||||
|
if self.config.block_title == '':
|
||||||
|
return
|
||||||
|
block_title = re.compile(self.config.block_title)
|
||||||
for div in [_ for _ in self.main_divs.find_all('div', recursive=True)]:
|
for div in [_ for _ in self.main_divs.find_all('div', recursive=True)]:
|
||||||
block_divs = [_ for _ in div.find_all('h3', recursive=True)
|
block_divs = [_ for _ in div.find_all('h3', recursive=True)
|
||||||
if self.config.block_title.search(_.text) is not None]
|
if block_title.search(_.text) is not None]
|
||||||
_ = div.decompose() if len(block_divs) else None
|
_ = div.decompose() if len(block_divs) else None
|
||||||
|
|
||||||
def remove_block_url(self) -> None:
|
def remove_block_url(self) -> None:
|
||||||
if not self.main_divs:
|
if not self.main_divs:
|
||||||
return
|
return
|
||||||
|
if self.config.block_url == '':
|
||||||
|
return
|
||||||
|
block_url = re.compile(self.config.block_url)
|
||||||
for div in [_ for _ in self.main_divs.find_all('div', recursive=True)]:
|
for div in [_ for _ in self.main_divs.find_all('div', recursive=True)]:
|
||||||
block_divs = [_ for _ in div.find_all('a', recursive=True)
|
block_divs = [_ for _ in div.find_all('a', recursive=True)
|
||||||
if self.config.block_url.search(_.attrs['href']) is not None]
|
if block_url.search(_.attrs['href']) is not None]
|
||||||
_ = div.decompose() if len(block_divs) else None
|
_ = div.decompose() if len(block_divs) else None
|
||||||
|
|
||||||
def collapse_sections(self) -> None:
|
def collapse_sections(self) -> None:
|
||||||
|
|
|
@ -15,8 +15,8 @@ class Config:
|
||||||
open(os.path.join(app_config['STATIC_FOLDER'],
|
open(os.path.join(app_config['STATIC_FOLDER'],
|
||||||
'css/variables.css')).read())
|
'css/variables.css')).read())
|
||||||
self.block = os.getenv('WHOOGLE_CONFIG_BLOCK', '')
|
self.block = os.getenv('WHOOGLE_CONFIG_BLOCK', '')
|
||||||
self.block_title = re.compile(os.getenv('WHOOGLE_CONFIG_BLOCK_TITLE', '^$'))
|
self.block_title = os.getenv('WHOOGLE_CONFIG_BLOCK_TITLE', '')
|
||||||
self.block_url = re.compile(os.getenv('WHOOGLE_CONFIG_BLOCK_URL', '^$'))
|
self.block_url = os.getenv('WHOOGLE_CONFIG_BLOCK_URL', '')
|
||||||
self.ctry = os.getenv('WHOOGLE_CONFIG_COUNTRY', '')
|
self.ctry = os.getenv('WHOOGLE_CONFIG_COUNTRY', '')
|
||||||
self.theme = os.getenv('WHOOGLE_CONFIG_THEME', '')
|
self.theme = os.getenv('WHOOGLE_CONFIG_THEME', '')
|
||||||
self.safe = read_config_bool('WHOOGLE_CONFIG_SAFE')
|
self.safe = read_config_bool('WHOOGLE_CONFIG_SAFE')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user