1
0
This commit is contained in:
Jon Michael Aanes 2024-11-28 22:14:33 +01:00
parent 1f3bef0772
commit a99f2c134d
Signed by: Jmaa
SSH Key Fingerprint: SHA256:Ab0GfHGCblESJx7JRE4fj4bFy/KRpeLhi41y4pF3sNA
3 changed files with 16 additions and 7 deletions

View File

@ -59,7 +59,10 @@ def assert_good_value_repr(r):
def to_quickstatements_v1_item(
subject, lines, skip_impossible=True, skip_already_syncronized=True
subject,
lines,
skip_impossible=True,
skip_already_syncronized=True,
):
# assert '@id' not in subject, 'TODO: Linked subjects'
subject_id = fmt_value(subject, True) if '@id' in subject else 'LAST'
@ -103,12 +106,14 @@ def to_quickstatements_v1_item(
if skip_impossible and predicate_str.startswith('"'):
logging.warning(
'Bad line: %s (Lines must not start with ")', predicate_str
'Bad line: %s (Lines must not start with ")',
predicate_str,
)
continue
if '' in line and skip_impossible:
logging.warning(
'Bad line: %s (Lines must not contain empty names)', line
'Bad line: %s (Lines must not contain empty names)',
line,
)
continue
assert 'None' not in line, line

View File

@ -21,7 +21,7 @@ class Concept:
for k, v in pairs.items():
keys = canonical_keys(k, context)
self.pairs.append(
{'canonical_key': keys[0], 'keys': set(keys), 'values': v}
{'canonical_key': keys[0], 'keys': set(keys), 'values': v},
)
self.regenerate_by_keys()
@ -36,7 +36,7 @@ class Concept:
'canonical_key': p['canonical_key'],
'keys': set(p['keys']),
'values': p['values'],
}
},
)
new.regenerate_by_keys()
return new

View File

@ -94,7 +94,8 @@ def get_triples_internal(subject, predicate, object):
params['page'] = current_page
url = (
requests.Request(
url='https://query.wikidata.org/bigdata/ldf', params=params
url='https://query.wikidata.org/bigdata/ldf',
params=params,
)
.prepare()
.url
@ -142,6 +143,9 @@ def get_triples(client, subject=None, predicate=None, object=None):
def get_backlinks(client, predicate, object):
for subject, _, _ in get_triples(
client, subject=None, predicate=predicate, object=object
client,
subject=None,
predicate=predicate,
object=object,
):
yield subject