Skip to content

Commit

Permalink
Determine min_length value during creation of the filer
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasPietzschmann committed Jun 28, 2024
1 parent 3834970 commit 6f9341a
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions extrakto.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ def __init__(self, *, min_length=None, alt=False, prefix_name=False):
lstrip=sect.get("lstrip", ""),
rstrip=sect.get("rstrip", ""),
alt=alt,
min_length=sect.getint("min_length", MIN_LENGTH_DEFAULT),
# prefer global min_length, fallback to filter specific
min_length=(
self.min_length
if self.min_length is not None
else sect.getint("min_length", MIN_LENGTH_DEFAULT)
),
)

def __getitem__(self, key):
Expand Down Expand Up @@ -126,12 +131,7 @@ def filter(self, text):
if self.rstrip:
item = item.rstrip(self.rstrip)

# prefer global min_length, fallback to filter specific
if len(item) >= (
self.extrakto.min_length
if self.extrakto.min_length is not None
else self.min_length
):
if len(item) >= self.min_length:
if not self.exclude or not re.search(self.exclude, item, re.I):
if self.extrakto.alt:
for i, altre in enumerate(self.alt):
Expand Down

0 comments on commit 6f9341a

Please sign in to comment.