Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6f9341a

Browse files
committedJun 28, 2024··
Determine min_length value during creation of the filer
1 parent 3834970 commit 6f9341a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎extrakto.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,12 @@ def __init__(self, *, min_length=None, alt=False, prefix_name=False):
7373
lstrip=sect.get("lstrip", ""),
7474
rstrip=sect.get("rstrip", ""),
7575
alt=alt,
76-
min_length=sect.getint("min_length", MIN_LENGTH_DEFAULT),
76+
# prefer global min_length, fallback to filter specific
77+
min_length=(
78+
self.min_length
79+
if self.min_length is not None
80+
else sect.getint("min_length", MIN_LENGTH_DEFAULT)
81+
),
7782
)
7883

7984
def __getitem__(self, key):
@@ -126,12 +131,7 @@ def filter(self, text):
126131
if self.rstrip:
127132
item = item.rstrip(self.rstrip)
128133

129-
# prefer global min_length, fallback to filter specific
130-
if len(item) >= (
131-
self.extrakto.min_length
132-
if self.extrakto.min_length is not None
133-
else self.min_length
134-
):
134+
if len(item) >= self.min_length:
135135
if not self.exclude or not re.search(self.exclude, item, re.I):
136136
if self.extrakto.alt:
137137
for i, altre in enumerate(self.alt):

0 commit comments

Comments
 (0)
Please sign in to comment.