iolanta 1.2.8__py3-none-any.whl → 1.2.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -432,6 +432,25 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
432
432
  query_result['bindings'] = bindings
433
433
  return query_result
434
434
 
435
+ def _is_loaded(self, uri: URIRef) -> bool:
436
+ """Find out if this URI in the graph already."""
437
+ return funcy.first(
438
+ self.graph.quads((
439
+ uri,
440
+ IOLANTA['last-loaded-time'],
441
+ None,
442
+ URIRef('iolanta://_meta'),
443
+ )),
444
+ ) is not None
445
+
446
+ def _mark_as_loaded(self, uri: URIRef):
447
+ self.graph.add((
448
+ uri,
449
+ IOLANTA['last-loaded-time'],
450
+ Literal(datetime.datetime.now()),
451
+ URIRef('iolanta://_meta'),
452
+ ))
453
+
435
454
  def load( # noqa: C901, WPS210, WPS212, WPS213, WPS231
436
455
  self,
437
456
  source: URIRef,
@@ -448,25 +467,23 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
448
467
  # fails.
449
468
  return Skipped()
450
469
 
470
+ if url.fragment:
471
+ # Fragment on an HTML page resolves to that same page. Let us remove
472
+ # this ambiguity, then.
473
+ # TODO: It works differently for JSON-LD documents AFAIK. Need to
474
+ # double check that.
475
+ url = url.with_fragment(None)
476
+ source = URIRef(str(url))
477
+
451
478
  new_source = self._apply_redirect(source)
452
479
  if new_source != source:
453
480
  return self.load(new_source)
454
481
 
455
482
  source_uri = normalize_term(source)
456
- existing_triple = funcy.first(
457
- self.graph.quads(
458
- (
459
- None,
460
- None,
461
- None,
462
- source_uri,
463
- ),
464
- ),
465
- )
466
- if existing_triple is not None:
483
+ if self._is_loaded(source_uri):
467
484
  return Skipped()
468
485
  else:
469
- self.logger.info(f'Existing triples not found for {source_uri}')
486
+ self.logger.info(f'{source_uri} is not loaded yet')
470
487
 
471
488
  # FIXME This is definitely inefficient. However, python-yaml-ld caches
472
489
  # the document, so the performance overhead is not super high.
@@ -510,6 +527,8 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
510
527
  RDFS.Class,
511
528
  ))
512
529
 
530
+ self._mark_as_loaded(source_uri)
531
+
513
532
  return Loaded()
514
533
 
515
534
  except Exception as err:
@@ -533,6 +552,9 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
533
552
  RDF.type,
534
553
  RDFS.Class,
535
554
  ))
555
+
556
+ self._mark_as_loaded(source_uri)
557
+
536
558
  return Loaded()
537
559
 
538
560
  if _resolved_source:
@@ -557,6 +579,8 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
557
579
  RDFS.Class,
558
580
  ))
559
581
 
582
+ self._mark_as_loaded(source_uri)
583
+
560
584
  try: # noqa: WPS225
561
585
  ld_rdf = yaml_ld.to_rdf(source)
562
586
  except ConnectionError as name_resolution_error:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iolanta
3
- Version: 1.2.8
3
+ Version: 1.2.9
4
4
  Summary: Semantic Web browser
5
5
  License: MIT
6
6
  Author: Anatoly Scherbakov
@@ -33,12 +33,38 @@ Requires-Dist: rich (>=13.3.1)
33
33
  Requires-Dist: textual (>=0.83.0)
34
34
  Requires-Dist: typer (>=0.9.0)
35
35
  Requires-Dist: watchfiles (>=1.0.4,<2.0.0)
36
- Requires-Dist: yaml-ld (>=1.1.3)
36
+ Requires-Dist: yaml-ld (>=1.1.4)
37
37
  Requires-Dist: yarl (>=1.9.4)
38
38
  Description-Content-Type: text/markdown
39
39
 
40
- # iolanta
40
+ # iolanta | Linked Data browser
41
41
 
42
- Stub repo for the iolanta browser.
42
+ ---
43
43
 
44
+ [![Build Status](https://github.com/iolanta-tech/iolanta/workflows/test/badge.svg?branch=master&event=push)](https://github.com/iolanta-tech/iolanta/actions?query=workflow%3Atest)
45
+ [![codecov](https://codecov.io/gh/iolanta-tech/iolanta/branch/master/graph/badge.svg)](https://codecov.io/gh/iolanta-tech/iolanta)
46
+ [![Python Version](https://img.shields.io/pypi/pyversions/iolanta.svg)](https://pypi.org/project/iolanta/)
47
+ [![wemake-python-styleguide](https://img.shields.io/badge/style-wemake-000000.svg)](https://github.com/wemake-services/wemake-python-styleguide)
48
+
49
+ ![Iolanta cover image](docs/assets/cover.webp)
50
+
51
+ ## 📦 Install with `pip`
52
+
53
+ ```shell
54
+ pip install iolanta
55
+ ```
56
+
57
+ ## Try it out!
58
+
59
+ Explore a Nanopublication:
60
+
61
+ ```shell
62
+ iolanta https://w3id.org/np/RA7OYmnx-3ln_AY233lElN01wSDJWDOXPz061Ah93EQ2I
63
+ ```
64
+
65
+
66
+
67
+ ![](docs/screenshots/w3id.org.np.ra7oymnx-3ln_ay233leln01wsdjwdoxpz061ah93eq2i.svg)
68
+
69
+ See more [in the docs](https://iolanta.tech).
44
70
 
@@ -14,7 +14,7 @@ iolanta/conversions.py,sha256=hbLwRF1bAbOxy17eMWLHhYksbdCWN-v4-0y0wn3XSSg,1185
14
14
  iolanta/cyberspace/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  iolanta/cyberspace/inference/wikibase-claim.sparql,sha256=JSawj3VTc9ZPoU9mvh1w1AMYb3cWyZ3x1rEYWUsKZ6A,209
16
16
  iolanta/cyberspace/inference/wikibase-statement-property.sparql,sha256=SkSHZZlxWVDwBM3aLo0Q7hLuOj9BsIQnXtcuAuwaxqU,240
17
- iolanta/cyberspace/processor.py,sha256=G740tg93-vkSrOgPm8ll8dA18UwbZEgtlg0eXt49wes,20153
17
+ iolanta/cyberspace/processor.py,sha256=04_aMktZfThOKq6FmbSsruzcaAp5TUcRKXu_JXv4ZKo,20927
18
18
  iolanta/data/cli.yaml,sha256=TsnldYXoY5GIzoNuPDvwBKGw8eAEForZW1FCKqKI0Kg,1029
19
19
  iolanta/data/context.yaml,sha256=OULEeDkSqshabaXF_gMujgwFLDJvt9eQn_9FftUlSUw,1424
20
20
  iolanta/data/html.yaml,sha256=hVFdLWLy8FMY8xpOrJMYc-tE3S0Nq83xuxVkjRW_7rI,517
@@ -128,7 +128,7 @@ iolanta/widgets/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
128
128
  iolanta/widgets/mixin.py,sha256=nDRCOc-gizCf1a5DAcYs4hW8eZEd6pHBPFsfm0ncv7E,251
129
129
  ldflex/__init__.py,sha256=8IELqR55CQXuI0BafjobXSK7_kOc-qKVTrEtEwXnZRA,33
130
130
  ldflex/ldflex.py,sha256=omKmOo5PUyn8Evw4q_lqKCJOq6yqVOcLAYxnYkdwOUs,3332
131
- iolanta-1.2.8.dist-info/METADATA,sha256=ZuobBaJiRgngoHBJuRTNrI8CZbn0KT_vPtHZP9QfkQ0,1361
132
- iolanta-1.2.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
133
- iolanta-1.2.8.dist-info/entry_points.txt,sha256=fIp9g4kzjSNcTsTSjUCk4BIG3laHd3b3hUZlkjgFAGU,179
134
- iolanta-1.2.8.dist-info/RECORD,,
131
+ iolanta-1.2.9.dist-info/METADATA,sha256=5hu-_eus5cPDpyWqMlB0_SzvWrtEvl4gYrqeI9Kfkmo,2294
132
+ iolanta-1.2.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
133
+ iolanta-1.2.9.dist-info/entry_points.txt,sha256=fIp9g4kzjSNcTsTSjUCk4BIG3laHd3b3hUZlkjgFAGU,179
134
+ iolanta-1.2.9.dist-info/RECORD,,