iolanta 1.2.9__py3-none-any.whl → 1.2.11__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.
iolanta/cli/main.py CHANGED
@@ -112,7 +112,7 @@ def render_command( # noqa: WPS231, WPS238, WPS210, C901
112
112
 
113
113
  try:
114
114
  renderable, stack = iolanta.render(
115
- node=node,
115
+ node=URIRef(node),
116
116
  as_datatype=URIRef(as_datatype),
117
117
  )
118
118
 
@@ -50,6 +50,9 @@ NORMALIZE_TERMS_MAP = MappingProxyType({
50
50
 
51
51
  REASONING_ENABLED = True
52
52
  OWL_REASONING_ENABLED = False
53
+ INDICES = [
54
+ URIRef('https://iolanta.tech/visualizations/index.yaml'),
55
+ ]
53
56
 
54
57
 
55
58
  REDIRECTS = MappingProxyType({
@@ -67,7 +70,10 @@ REDIRECTS = MappingProxyType({
67
70
  # This one does not answer via HTTPS :(
68
71
  URIRef('https://xmlns.com/foaf/0.1/'): URIRef('http://xmlns.com/foaf/0.1/'),
69
72
  URIRef('https://www.nanopub.org/nschema'): URIRef(
70
- 'https://www.nanopub.net/nschema',
73
+ 'https://www.nanopub.net/nschema#',
74
+ ),
75
+ URIRef('https://nanopub.org/nschema'): URIRef(
76
+ 'https://nanopub.net/nschema#',
71
77
  ),
72
78
  URIRef(PROV): URIRef('https://www.w3.org/ns/prov-o'),
73
79
  })
@@ -278,6 +284,15 @@ def _extract_nanopublication_uris(
278
284
  )
279
285
 
280
286
 
287
+ def apply_redirect(source: URIRef) -> URIRef:
288
+ """Rewrite the URL."""
289
+ for pattern, destination in REDIRECTS.items():
290
+ if source.startswith(pattern):
291
+ return destination
292
+
293
+ return source
294
+
295
+
281
296
  @dataclasses.dataclass(frozen=True)
282
297
  class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
283
298
  """
@@ -294,6 +309,7 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
294
309
  def __post_init__(self):
295
310
  """Note that we do not presently need OWL inference."""
296
311
  self.graph.last_not_inferred_source = None
312
+ self.graph._indices_loaded = False
297
313
 
298
314
  def _infer_with_sparql(self):
299
315
  """
@@ -353,17 +369,12 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
353
369
  ]
354
370
  self.graph.addN(inferred_quads)
355
371
 
356
- def _apply_redirect(self, source: URIRef) -> URIRef:
357
- for pattern, destination in REDIRECTS.items():
358
- if source.startswith(pattern):
359
- self.logger.info(
360
- 'Rewriting: {source} → {destination}',
361
- source=source,
362
- destination=destination,
363
- )
364
- return destination
372
+ def _maybe_load_indices(self):
373
+ if not self.graph._indices_loaded:
374
+ for index in INDICES:
375
+ self.load(index)
365
376
 
366
- return source
377
+ self.graph._indices_loaded = True
367
378
 
368
379
  def query( # noqa: WPS211, WPS210, WPS231, C901
369
380
  self,
@@ -378,6 +389,8 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
378
389
  namespaces. The given base is used to resolve relative URIs in
379
390
  the query and will be overridden by any BASE given in the query.
380
391
  """
392
+ self._maybe_load_indices()
393
+
381
394
  initBindings = initBindings or {}
382
395
  initNs = initNs or {}
383
396
 
@@ -406,7 +419,7 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
406
419
  try:
407
420
  self.load(url)
408
421
  except Exception as err:
409
- self.logger.error('Failed to load %s: %s', url, err)
422
+ self.logger.error(f'Failed to load {url}: {err}', url, err)
410
423
 
411
424
  self.maybe_apply_inference()
412
425
 
@@ -451,6 +464,15 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
451
464
  URIRef('iolanta://_meta'),
452
465
  ))
453
466
 
467
+ def _follow_is_visualized_with_links(self, uri: URIRef):
468
+ """Follow `dcterms:isReferencedBy` links."""
469
+ self.logger.info(f'Following links for {uri}…')
470
+ triples = self.graph.triples((uri, DCTERMS.isReferencedBy, None))
471
+ for _, _, visualization in triples:
472
+ if isinstance(visualization, URIRef):
473
+ self.load(visualization)
474
+ self.logger.info('Links followed.')
475
+
454
476
  def load( # noqa: C901, WPS210, WPS212, WPS213, WPS231
455
477
  self,
456
478
  source: URIRef,
@@ -473,10 +495,17 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
473
495
  # TODO: It works differently for JSON-LD documents AFAIK. Need to
474
496
  # double check that.
475
497
  url = url.with_fragment(None)
476
- source = URIRef(str(url))
498
+ source = URIRef(str(f'{url}#'))
499
+
500
+ self._follow_is_visualized_with_links(source)
477
501
 
478
- new_source = self._apply_redirect(source)
502
+ new_source = apply_redirect(source)
479
503
  if new_source != source:
504
+ self.logger.info(
505
+ 'Rewriting: {source} → {new_source}',
506
+ source=source,
507
+ new_source=new_source,
508
+ )
480
509
  return self.load(new_source)
481
510
 
482
511
  source_uri = normalize_term(source)
@@ -601,7 +630,7 @@ class GlobalSPARQLProcessor(Processor): # noqa: WPS338, WPS214
601
630
  quads = list(
602
631
  parse_quads(
603
632
  quads_document=ld_rdf,
604
- graph=source, # type: ignore
633
+ graph=source_uri,
605
634
  blank_node_prefix=str(source),
606
635
  ),
607
636
  )
@@ -45,8 +45,7 @@ class PageTitle(IolantaWidgetMixin, Static):
45
45
  title = event.worker.result
46
46
  if self.extra:
47
47
  title = f'{title} {self.extra}'
48
- self.renderable = title
49
- self.refresh()
48
+ self.update(title)
50
49
 
51
50
  case WorkerState.ERROR:
52
51
  raise ValueError(event)
@@ -258,6 +258,10 @@ class PageSwitcher(IolantaWidgetMixin, ContentSwitcher): # noqa: WPS214
258
258
  return not is_loading
259
259
  case 'abort':
260
260
  return is_loading
261
+ case 'back':
262
+ return bool(self.history.past)
263
+ case 'forward':
264
+ return bool(self.history.future)
261
265
 
262
266
  return True
263
267
 
@@ -288,12 +292,15 @@ class PageSwitcher(IolantaWidgetMixin, ContentSwitcher): # noqa: WPS214
288
292
  def action_back(self):
289
293
  """Go backward."""
290
294
  self.current = self.history.back().page_id
291
- self.focus()
295
+ if page := self.visible_content:
296
+ page.focus()
292
297
 
293
298
  def action_forward(self):
294
299
  """Go forward."""
295
300
  self.current = self.history.forward().page_id
296
301
  self.focus()
302
+ if page := self.visible_content:
303
+ page.focus()
297
304
 
298
305
 
299
306
  class ConsoleSwitcher(ContentSwitcher):
@@ -1,3 +1,3 @@
1
1
  SELECT ?vocab WHERE {
2
- ?iri iolanta:visualized-with ?vocab .
2
+ ?iri dcterms:isReferencedBy ?vocab .
3
3
  }
iolanta/iolanta.py CHANGED
@@ -300,9 +300,7 @@ class Iolanta: # noqa: WPS214
300
300
  self.add(plugin.data_files)
301
301
  except Exception as error:
302
302
  self.logger.error(
303
- 'Cannot load %s plugin data files: %s',
304
- plugin,
305
- error,
303
+ f'Cannot load {plugin} plugin data files: {error}',
306
304
  )
307
305
 
308
306
  def __post_init__(self):
iolanta/parse_quads.py CHANGED
@@ -23,7 +23,6 @@ def parse_term( # noqa: C901
23
23
  term_value = term['value']
24
24
 
25
25
  if term_type == 'IRI':
26
- raise_if_term_is_qname(term_value)
27
26
  return URIRef(term_value)
28
27
 
29
28
  if term_type == 'literal':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iolanta
3
- Version: 1.2.9
3
+ Version: 1.2.11
4
4
  Summary: Semantic Web browser
5
5
  License: MIT
6
6
  Author: Anatoly Scherbakov
@@ -33,7 +33,7 @@ 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.4)
36
+ Requires-Dist: yaml-ld (>=1.1.7)
37
37
  Requires-Dist: yarl (>=1.9.4)
38
38
  Description-Content-Type: text/markdown
39
39
 
@@ -6,7 +6,7 @@ iolanta/cli/formatters/choose.py,sha256=Ac4hNoptvnhuJB77K9KOn5oMF7j2RxmNuaLko28W
6
6
  iolanta/cli/formatters/csv.py,sha256=OVucZxhcMjihUli0wkbSOKo500-i7DNV0Zdf6oIougU,753
7
7
  iolanta/cli/formatters/json.py,sha256=jkNldFApSWw0kcMkeIPvI2Vt4JTE-Rvx5mWqKJb3Sj4,741
8
8
  iolanta/cli/formatters/pretty.py,sha256=Ik75CR5GMBDJCvES9eF0bQPj64ZJD40iFDSSZH0s9aA,2920
9
- iolanta/cli/main.py,sha256=-VS9B8kEBgJI6dl4W1cT4mZzWkANnMG1M6JnlXpdSKk,3126
9
+ iolanta/cli/main.py,sha256=93pfYqhXsldasyh1vnJin8Tt6EkUiCsVrwA4v4f6Ibc,3134
10
10
  iolanta/cli/models.py,sha256=cjbpowdzI4wAP0DUk3qoVHyimk6AZwlXi9CGmusZTuM,159
11
11
  iolanta/cli/pretty_print.py,sha256=M6E3TmhzA6JY5GeUVmDZLmOh5u70-393PVit4voFKDI,977
12
12
  iolanta/context.py,sha256=bZR-tbZIrDQ-Vby01PMDZ6ifxM-0YMK68RJvAsyqCTs,507
@@ -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=04_aMktZfThOKq6FmbSsruzcaAp5TUcRKXu_JXv4ZKo,20927
17
+ iolanta/cyberspace/processor.py,sha256=rxO5MaZEoXD2Kzknq7eRH3yuv8kQ5UILy8qkJxramMY,21828
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
@@ -46,7 +46,7 @@ iolanta/facets/html/code_literal.py,sha256=qCddzBrg6Y5XMIKohFQ52Tf9GPOcU7bj83tfA
46
46
  iolanta/facets/html/default.py,sha256=Dmf_kYiL2M954iigyYsiWrMstwZ1nvxKetuR6aW3xYY,647
47
47
  iolanta/facets/icon.py,sha256=ddZcolx1Q5_wo3w0jqiCzcc5Lsru6-jA7s7oAd1T8Og,494
48
48
  iolanta/facets/locator.py,sha256=tFwxGT4ujwEjwkgTevK6gwWfj3_1lU9Q305IU7a-I3Y,7697
49
- iolanta/facets/page_title.py,sha256=s70A9w39O7J9Di3ni2ufRGsNctAW-eTzPTuP_wzWAtI,1446
49
+ iolanta/facets/page_title.py,sha256=CI2V8f7zSSrwbQginhyycZttNoAZTHq34SiO8Ql59bQ,1410
50
50
  iolanta/facets/qname.py,sha256=ztyBbjjcW8dNZzuiNMqhcWfAUxk-gSjbseVGrQE7kVY,531
51
51
  iolanta/facets/textual_browser/__init__.py,sha256=sKgDvXOwib9n9d63kdtKCEv26-FoL0VN6zxDmfcheZ8,104
52
52
  iolanta/facets/textual_browser/app.py,sha256=6-cmEkwRqj9UptVvXKVNIxT3PcDDOZP1OLpv8gPmB_Q,3202
@@ -56,7 +56,7 @@ iolanta/facets/textual_browser/home.py,sha256=GfDD1G2HiwdLkPkNdcYRqVIxDl5tWH9few
56
56
  iolanta/facets/textual_browser/location.py,sha256=w0La8bVTpJiVo1_hFTDQeIUdDdqfhYnoihuZW-f130c,205
57
57
  iolanta/facets/textual_browser/models.py,sha256=DqTBjhkkTt5mNwqr4DzNbPSqzV-QtNqfKj7wpn6T3ao,173
58
58
  iolanta/facets/textual_browser/page.py,sha256=NkcQ5rSKZRbp63C8ozgsR_iVhcKHGv_SytUCQyGa7ss,786
59
- iolanta/facets/textual_browser/page_switcher.py,sha256=Rbfa7HjGMw-OFOUfq8J8A3pIlrY0iP3ZJQrWl_US5tQ,9693
59
+ iolanta/facets/textual_browser/page_switcher.py,sha256=1-mWI56n2gLDThPBjfqHLun3utkUYdOkKSzejCIziEk,9953
60
60
  iolanta/facets/textual_class/__init__.py,sha256=tiL0p-3JspGcBRj4qa3rmoBFAuadk71l2ja2lJN6CEs,75
61
61
  iolanta/facets/textual_class/facets.py,sha256=W3-N7bekk-bKwrb2rTPwmySGF42-uV7aqLPAiHwFSU4,6496
62
62
  iolanta/facets/textual_class/sparql/instances.sparql,sha256=tmG4tuYrROKo3A7idjOEblAeNPXiiExHxc6k3fhalSM,113
@@ -85,7 +85,7 @@ iolanta/facets/textual_nanopublication/term_widget.py,sha256=uI5msCTSIYumAIS3I8n
85
85
  iolanta/facets/textual_ontology/__init__.py,sha256=3H6bfYaEbXFr90C6ZpGWC4O-24uaO18tnTXx7mckQSA,94
86
86
  iolanta/facets/textual_ontology/facets.py,sha256=60g8ANmePb9_i_-d4ui-FdtNwg9aktrOKXHkTQtLp1w,3338
87
87
  iolanta/facets/textual_ontology/sparql/terms.sparql,sha256=oVLxN452nqog_95qRaTWnvar6rxPNxPrRonSo7oFFTg,324
88
- iolanta/facets/textual_ontology/sparql/visualization-vocab.sparql,sha256=UNbU2Qt5C1Vq-CvdVhok7wecnu6p_IDtw7A8n_g6lBs,66
88
+ iolanta/facets/textual_ontology/sparql/visualization-vocab.sparql,sha256=q9TmU15deL0da28mpo_8W8fgMSEcENfYeqLyM0zVbTg,65
89
89
  iolanta/facets/textual_provenance/__init__.py,sha256=k5-_iK8Lrdwr5ZEJaDxq-UhGYe4G_adXVqGfOA5DAP8,114
90
90
  iolanta/facets/textual_provenance/facets.py,sha256=vv3UQsI2duB36DW5Zkw3sqgAXBPmK_xAo7cU0O7jF8g,3767
91
91
  iolanta/facets/textual_provenance/sparql/graphs.sparql,sha256=B45uKFd-1vrBuMDSbTURjUUEjHt51vAbqdL4tUcgMvk,103
@@ -96,7 +96,7 @@ iolanta/facets/title/sparql/title.sparql,sha256=4rz47tjwX2OJavWMzftaYKil1-ZHB76Z
96
96
  iolanta/facets/wikibase_statement_title/__init__.py,sha256=_yk1akxgSJOiUBJIc8QGrD2vovvmx_iw_vJDuv1rD7M,91
97
97
  iolanta/facets/wikibase_statement_title/facets.py,sha256=mUH7twlAgoeX7DgLQuRBQv4ORT6GWbN-0eJ1aliSfiQ,724
98
98
  iolanta/facets/wikibase_statement_title/sparql/statement-title.sparql,sha256=n07DQWxKqB5c3CA4kacq2HSN0R0dLgnMnLP1AxMo5YA,320
99
- iolanta/iolanta.py,sha256=kSMYvDmyjpSDgqLppeI835fHRl1YOVfuwiodIrVlUwo,12954
99
+ iolanta/iolanta.py,sha256=cIfhM9zhositho4C6jZ2th2oB3d50BSlYsRRozS4tP4,12911
100
100
  iolanta/loaders/__init__.py,sha256=QTiKCsQc1BTS-IlY2CQsN9iVpEIPqYFvI9ERMYVZCbU,99
101
101
  iolanta/loaders/base.py,sha256=-DxYwqG1bfDXB2p_S-mKpkc_3Sh14OHhePbe65Iq3-s,3381
102
102
  iolanta/loaders/data_type_choice.py,sha256=zRUXBIzjvuW28P_dhMDVevE9C8EFEIx2_X39WydWrtM,1982
@@ -109,7 +109,7 @@ iolanta/loaders/scheme_choice.py,sha256=GHA4JAD-Qq3uNdej4vs_bCrN1WMRshVRvOMxaYyP
109
109
  iolanta/models.py,sha256=L0iFaga4-PCaWP18WmT03NLK_oT7q49V0WMTQskoffI,2824
110
110
  iolanta/namespaces.py,sha256=fyWDCGPwU8Cs8d-Vmci4H0-fuIe7BMSevvEKFvG7Gf4,1153
111
111
  iolanta/node_to_qname.py,sha256=a82_qpgT87cbekY_76tTkl4Z-6Rz6am4UGIQChUf9Y0,794
112
- iolanta/parse_quads.py,sha256=yOI154hGRCNv4UjEuhicP0cQWNWid_52mE86VWYfH8w,2833
112
+ iolanta/parse_quads.py,sha256=nQeX9zSjDoITH1lmd25xhKq44bFTqcayFbAguXfFyh4,2790
113
113
  iolanta/parsers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
114
114
  iolanta/parsers/base.py,sha256=ZFjj0BLzW4985BdC6PwbngenhMuSYW5mNLpprZRWjhA,1048
115
115
  iolanta/parsers/dict_parser.py,sha256=t_OK2meUh49DqSaOYkSgEwxMKUNNgjJY8rZAyL4NQKI,4546
@@ -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.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,,
131
+ iolanta-1.2.11.dist-info/METADATA,sha256=2wGXN9mncu09r8MrbLUvMM_VYavsuM6u7dkQTEbLNsc,2295
132
+ iolanta-1.2.11.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
133
+ iolanta-1.2.11.dist-info/entry_points.txt,sha256=fIp9g4kzjSNcTsTSjUCk4BIG3laHd3b3hUZlkjgFAGU,179
134
+ iolanta-1.2.11.dist-info/RECORD,,