Skip to content

Commit

Permalink
match a QID against the whole input string, avoids cases like "Q1blab…
Browse files Browse the repository at this point in the history
…labla"
  • Loading branch information
marfox committed Oct 22, 2021
1 parent 7d04642 commit 1847ef1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions soweego/ingester/wikidata_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import json
import logging
from datetime import date
from re import match
from re import fullmatch
from typing import Iterable

import click
Expand Down Expand Up @@ -458,7 +458,7 @@ def _add_or_reference_works(
) -> None:
work, predicate, person = statement
# Parse value into an item in case of QID
qid = match(QID_REGEX, person)
qid = fullmatch(QID_REGEX, person)
if not qid:
LOGGER.warning(
"%s doesn't look like a QID, won't try to add the %s statement",
Expand Down Expand Up @@ -752,7 +752,7 @@ def _parse_value(value):
if not isinstance(value, str):
value = str(value)
# Build an item in case of QID
value_is_qid = match(QID_REGEX, value)
value_is_qid = fullmatch(QID_REGEX, value)
if value_is_qid:
return pywikibot.ItemPage(REPO, value_is_qid.group())
# Try to build a date
Expand Down

0 comments on commit 1847ef1

Please sign in to comment.