Skip to content

Commit c2a5e54

Browse files
committed
Avoid recursion when creating config
1 parent 41110e7 commit c2a5e54

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

journal_brief/format/config.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ def get_top(self, entries=None):
158158
Find the most frequently occurring set of key=value pairs
159159
160160
:param entries: iterable, providing entry dicts
161+
:return: list of remaining entries
161162
"""
162163
if entries is None:
163164
entries = self.all_entries
@@ -205,10 +206,7 @@ def get_top(self, entries=None):
205206

206207
log.debug("%s entries remaining", len(remaining))
207208
assert len(remaining) < len(entries)
208-
try:
209-
return self.get_top(remaining)
210-
except StopIteration:
211-
return top
209+
return remaining
212210

213211
def get_exclusions(self):
214212
"""
@@ -217,9 +215,15 @@ def get_exclusions(self):
217215
:return: list, Exclusion instances
218216
"""
219217
try:
220-
self.get_top()
218+
remaining = self.get_top()
221219
except StopIteration:
222220
pass
221+
else:
222+
try:
223+
while True:
224+
remaining = self.get_top(remaining)
225+
except StopIteration:
226+
pass
223227

224228
return self.exclusions
225229

0 commit comments

Comments
 (0)