Skip to content

Commit b097b10

Browse files
committed
fix(logging): restore two changes lost in the merge resolution
- semantic_search: test the query limit again, not SearchParam.limit - modify_search_results: restore the modify_single_result definition - wtsite: log the slot content via pformat instead of printing it - refs #130
1 parent adeb770 commit b097b10

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

‎src/osw/wiki_tools.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,10 @@ def semantic_search_(single_query):
323323
_logger.debug(f"Query '{single_query}' returned no results")
324324
else:
325325
_logger.debug(f"Query '{single_query}' returned {n} results")
326-
if n >= query.limit:
326+
# No limit in force, or 'limit=0' asking for no results at all as a
327+
# count format does, means the result count says nothing about
328+
# truncation
329+
if limit and n >= limit:
327330
warnings.warn(
328331
f"Query '{single_query}' returned {n} results, which meets the "
329332
f"requested limit of {limit}. Results are truncated - raise "

‎src/osw/wtsite.py‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from datetime import datetime
1515
from io import StringIO
1616
from pathlib import Path
17-
from pprint import pprint
17+
from pprint import pformat
1818
from time import sleep
1919
from typing import Any, Dict, List, Optional, Union
2020
from warnings import warn
@@ -643,19 +643,21 @@ def modify_search_results(
643643
titles = titles[0:limit]
644644
if param.log:
645645
_logger.debug(f"Found: {titles}")
646-
for title in titles:
646+
647+
def modify_single_result(title: str):
647648
wtpage = self.get_page(WtSite.GetPageParam(titles=[title])).pages[0]
648649
modify_page(wtpage)
649-
if log:
650+
if param.log:
650651
_logger.debug(f"\n======= {title} =======")
651652
for slot in wtpage._slots:
652653
content = wtpage.get_slot_content(slot)
653654
# if isinstance(content, dict): content = json.dumps(content)
654655
_logger.debug(f" ==== {title}:{slot} ==== ")
655-
pprint(content)
656+
_logger.debug(pformat(content))
656657
_logger.debug("\n")
657658
if not param.dryrun:
658-
wtpage.edit(comment)
659+
wtpage.edit(param.comment)
660+
659661
if param.parallel:
660662
_ = parallelize(modify_single_result, titles, flush_at_end=param.log)
661663
else:

0 commit comments

Comments
 (0)