Skip to content

Commit

Permalink
Add warning when using qualifier/reference in Reference (#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeMyst authored Dec 20, 2023
1 parent 9e46a29 commit cf6b7a3
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wikibaseintegrator/models/references.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import logging
from typing import TYPE_CHECKING, Any

from wikibaseintegrator.models.basemodel import BaseModel
Expand All @@ -9,6 +10,8 @@
if TYPE_CHECKING:
from wikibaseintegrator.models.claims import Claim

log = logging.getLogger(__name__)


class References(BaseModel):
def __init__(self) -> None:
Expand All @@ -32,6 +35,13 @@ def get(self, hash: str | None = None) -> Reference | None:
def add(self, reference: Reference | Claim | None = None, action_if_exists: ActionIfExists = ActionIfExists.REPLACE_ALL) -> References:
from wikibaseintegrator.models.claims import Claim
if isinstance(reference, Claim):

if reference.qualifiers:
log.warning("WARNING: It is not possible to use a qualifier in a reference, it will be ignored.")

if reference.references:
log.warning("WARNING: It is not possible to use a reference in a reference, it will be ignored.")

reference = Reference(snaks=Snaks().add(Snak().from_json(reference.get_json()['mainsnak'])))

if reference is not None:
Expand Down

0 comments on commit cf6b7a3

Please sign in to comment.