Skip to content

Commit

Permalink
Actual changes, minor possible bug-fixes
Browse files Browse the repository at this point in the history
A separate commit for all of the changes that could
potentially break things, just to make it easier to
hunt for bugs later.
  • Loading branch information
kristian-clausal committed Feb 14, 2024
1 parent cbc8d0c commit dee2400
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/wiktextract/extractor/en/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -2121,10 +2121,10 @@ def recurse(
node: Union[str, WikiNode], seq: Union[list[str], tuple[str, ...]]
) -> Optional[WikiNode]:
# print(f"seq: {seq}")
if not seq:
return node
if not isinstance(node, WikiNode):
return None
if not seq:
return node
# print(f"node.kind: {node.kind}")
if node.kind in LEVEL_KINDS:
t = clean_node(wxr, None, node.largs[0])
Expand Down Expand Up @@ -2966,7 +2966,10 @@ def parse_translation_recurse(xlatnode: WikiNode) -> None:
sortid="page/2595",
)
sub = wxr.wtp.subsection
if sub.lower() in wxr.config.POS_SUBTITLES:
if (
sub is not None
and sub.lower() in wxr.config.POS_SUBTITLES
):
seq = [
language,
sub,
Expand All @@ -2980,8 +2983,10 @@ def parse_translation_recurse(xlatnode: WikiNode) -> None:
if subnode is not None:
parse_translations(data, subnode)
else:
wxr.wtp.errors(
"/translations link outside " "part-of-speech"
# This was broken for a long time, is this reached?
wxr.wtp.error(
"/translations link outside part-of-speech",
sortid="page/2985/20240214",
)

if (
Expand All @@ -2994,7 +2999,7 @@ def parse_translation_recurse(xlatnode: WikiNode) -> None:
sense_parts.append(x)
else:
parse_translation_recurse(x)
elif not sense:
elif not sense and isinstance(node, str):
sense_parts.append(node)
else:
wxr.wtp.debug(
Expand Down Expand Up @@ -3350,6 +3355,7 @@ def skip_template_fn(name: str, ht: TemplateArgs) -> Optional[str]:
if t_no_number in wxr.config.POS_SUBTITLES:
push_pos()
dt = wxr.config.POS_SUBTITLES.get(t_no_number)
assert dt is not None
pos = dt["pos"]
wxr.wtp.start_subsection(t)
if "debug" in dt:
Expand Down

0 comments on commit dee2400

Please sign in to comment.