iolanta 1.2.11__tar.gz → 2.0.1__tar.gz

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.
Files changed (134) hide show
  1. {iolanta-1.2.11 → iolanta-2.0.1}/PKG-INFO +1 -2
  2. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/formatters/choose.py +1 -1
  3. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/formatters/csv.py +1 -1
  4. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/formatters/json.py +1 -1
  5. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/formatters/pretty.py +1 -2
  6. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/main.py +1 -1
  7. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/facet.py +4 -29
  8. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/page_title.py +1 -1
  9. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/page_switcher.py +1 -1
  10. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_class/facets.py +1 -1
  11. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/widgets.py +2 -2
  12. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_graph/facets.py +1 -1
  13. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_graph_triples.py +1 -1
  14. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_nanopublication/nanopublication_widget.py +1 -1
  15. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_nanopublication/term_list_widget.py +1 -1
  16. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/iolanta.py +58 -16
  17. iolanta-2.0.1/iolanta/query_result.py +73 -0
  18. {iolanta-1.2.11 → iolanta-2.0.1}/pyproject.toml +1 -7
  19. iolanta-1.2.11/iolanta/stack.py +0 -11
  20. iolanta-1.2.11/ldflex/__init__.py +0 -1
  21. iolanta-1.2.11/ldflex/ldflex.py +0 -138
  22. {iolanta-1.2.11 → iolanta-2.0.1}/README.md +0 -0
  23. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/__init__.py +0 -0
  24. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/base_plugin.py +0 -0
  25. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/__init__.py +0 -0
  26. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/formatters/__init__.py +0 -0
  27. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/models.py +0 -0
  28. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cli/pretty_print.py +0 -0
  29. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/context.py +0 -0
  30. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/conversions.py +0 -0
  31. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cyberspace/__init__.py +0 -0
  32. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cyberspace/inference/wikibase-claim.sparql +0 -0
  33. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cyberspace/inference/wikibase-statement-property.sparql +0 -0
  34. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/cyberspace/processor.py +0 -0
  35. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/data/cli.yaml +0 -0
  36. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/data/context.yaml +0 -0
  37. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/data/html.yaml +0 -0
  38. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/data/iolanta.yaml +0 -0
  39. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/data/textual-browser.yaml +0 -0
  40. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/ensure_is_context.py +0 -0
  41. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/entry_points.py +0 -0
  42. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/errors.py +0 -0
  43. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/__init__.py +0 -0
  44. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/cli/__init__.py +0 -0
  45. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/cli/base.py +0 -0
  46. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/cli/default.py +0 -0
  47. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/cli/record.py +0 -0
  48. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/cli/sparql/link.sparql +0 -0
  49. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/cli/sparql/record.sparql +0 -0
  50. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/errors.py +0 -0
  51. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/foaf_person_title/__init__.py +0 -0
  52. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/foaf_person_title/facet.py +0 -0
  53. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/foaf_person_title/sparql/names.sparql +0 -0
  54. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/generic/__init__.py +0 -0
  55. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/generic/bool_literal.py +0 -0
  56. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/generic/date_literal.py +0 -0
  57. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/generic/default.py +0 -0
  58. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/generic/sparql/default.sparql +0 -0
  59. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/html/__init__.py +0 -0
  60. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/html/base.py +0 -0
  61. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/html/code_literal.py +0 -0
  62. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/html/default.py +0 -0
  63. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/icon.py +0 -0
  64. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/locator.py +0 -0
  65. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/qname.py +0 -0
  66. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/__init__.py +0 -0
  67. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/app.py +0 -0
  68. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/facet.py +0 -0
  69. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/history.py +0 -0
  70. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/home.py +0 -0
  71. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/location.py +0 -0
  72. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/models.py +0 -0
  73. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_browser/page.py +0 -0
  74. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_class/__init__.py +0 -0
  75. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_class/sparql/instances.sparql +0 -0
  76. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/__init__.py +0 -0
  77. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/facets.py +0 -0
  78. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/sparql/inverse-properties.sparql +0 -0
  79. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/sparql/label.sparql +0 -0
  80. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/sparql/nodes-for-property.sparql +0 -0
  81. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/sparql/properties.sparql +0 -0
  82. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/tcss/default.tcss +0 -0
  83. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/templates/default.md +0 -0
  84. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_default/triple_uri_ref.py +0 -0
  85. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_graph/__init__.py +0 -0
  86. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_graph/sparql/triples.sparql +0 -0
  87. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_link/__init__.py +0 -0
  88. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_link/facet.py +0 -0
  89. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_nanopublication/__init__.py +0 -0
  90. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_nanopublication/facet.py +0 -0
  91. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_nanopublication/models.py +0 -0
  92. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_nanopublication/term_widget.py +0 -0
  93. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_ontology/__init__.py +0 -0
  94. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_ontology/facets.py +0 -0
  95. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_ontology/sparql/terms.sparql +0 -0
  96. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_ontology/sparql/visualization-vocab.sparql +0 -0
  97. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_provenance/__init__.py +0 -0
  98. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_provenance/facets.py +0 -0
  99. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_provenance/sparql/graphs.sparql +0 -0
  100. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/textual_provenance/sparql/triples.sparql +0 -0
  101. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/title/__init__.py +0 -0
  102. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/title/facets.py +0 -0
  103. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/title/sparql/title.sparql +0 -0
  104. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/wikibase_statement_title/__init__.py +0 -0
  105. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/wikibase_statement_title/facets.py +0 -0
  106. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/facets/wikibase_statement_title/sparql/statement-title.sparql +0 -0
  107. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/__init__.py +0 -0
  108. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/base.py +0 -0
  109. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/data_type_choice.py +0 -0
  110. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/dict_loader.py +0 -0
  111. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/errors.py +0 -0
  112. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/http.py +0 -0
  113. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/local_directory.py +0 -0
  114. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/local_file.py +0 -0
  115. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/loaders/scheme_choice.py +0 -0
  116. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/models.py +0 -0
  117. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/namespaces.py +0 -0
  118. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/node_to_qname.py +0 -0
  119. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/parse_quads.py +0 -0
  120. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/parsers/__init__.py +0 -0
  121. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/parsers/base.py +0 -0
  122. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/parsers/dict_parser.py +0 -0
  123. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/parsers/errors.py +0 -0
  124. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/parsers/json.py +0 -0
  125. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/parsers/markdown.py +0 -0
  126. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/parsers/yaml.py +0 -0
  127. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/plugin.py +0 -0
  128. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/reformat_blank_nodes.py +0 -0
  129. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/resolvers/__init__.py +0 -0
  130. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/resolvers/base.py +0 -0
  131. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/resolvers/python_import.py +0 -0
  132. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/shortcuts.py +0 -0
  133. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/widgets/__init__.py +0 -0
  134. {iolanta-1.2.11 → iolanta-2.0.1}/iolanta/widgets/mixin.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: iolanta
3
- Version: 1.2.11
3
+ Version: 2.0.1
4
4
  Summary: Semantic Web browser
5
5
  License: MIT
6
6
  Author: Anatoly Scherbakov
@@ -19,7 +19,6 @@ Requires-Dist: diskcache (>=5.6.3)
19
19
  Requires-Dist: documented (>=0.1.1)
20
20
  Requires-Dist: dominate (>=2.6.0)
21
21
  Requires-Dist: funcy (>=2.0)
22
- Requires-Dist: iolanta-tables (>=0.1.7,<0.2.0) ; extra == "all"
23
22
  Requires-Dist: loguru (>=0.7.3)
24
23
  Requires-Dist: more-itertools (>=9.0.0)
25
24
  Requires-Dist: nanopub (>=2.0.1)
@@ -7,7 +7,7 @@ from iolanta.cli.formatters.json import print_json
7
7
  from iolanta.cli.formatters.pretty import pretty_print
8
8
  from iolanta.models import QueryResultsFormat
9
9
  from iolanta.node_to_qname import node_to_qname
10
- from ldflex.ldflex import SelectResult
10
+ from iolanta.query_result import SelectResult
11
11
 
12
12
 
13
13
  # @cli_print.instance(SelectResult)
@@ -4,7 +4,7 @@ import sys
4
4
  from classes import typeclass
5
5
  from rdflib import Graph
6
6
 
7
- from ldflex.ldflex import QueryResult, SelectResult
7
+ from iolanta.query_result import QueryResult, SelectResult
8
8
 
9
9
 
10
10
  @typeclass
@@ -4,7 +4,7 @@ import sys
4
4
  from classes import typeclass
5
5
  from rdflib import Graph
6
6
 
7
- from ldflex.ldflex import QueryResult, SelectResult
7
+ from iolanta.query_result import QueryResult, SelectResult
8
8
 
9
9
 
10
10
  @typeclass
@@ -1,5 +1,4 @@
1
1
  import itertools
2
- from datetime import date
3
2
  from typing import Union
4
3
 
5
4
  from classes import typeclass
@@ -10,7 +9,7 @@ from rich.table import Table
10
9
 
11
10
  from iolanta.cli.pretty_print import render_literal_value
12
11
  from iolanta.models import ComputedQName
13
- from ldflex.ldflex import QueryResult, SelectResult
12
+ from iolanta.query_result import QueryResult, SelectResult
14
13
 
15
14
 
16
15
  @typeclass
@@ -111,7 +111,7 @@ def render_command( # noqa: WPS231, WPS238, WPS210, C901
111
111
  )
112
112
 
113
113
  try:
114
- renderable, stack = iolanta.render(
114
+ renderable = iolanta.render(
115
115
  node=URIRef(node),
116
116
  as_datatype=URIRef(as_datatype),
117
117
  )
@@ -2,14 +2,12 @@ import inspect
2
2
  from dataclasses import dataclass, field
3
3
  from functools import cached_property
4
4
  from pathlib import Path
5
- from typing import Any, Generic, Iterable, List, Optional, TypeVar, Union
5
+ from typing import Any, Generic, Iterable, Optional, TypeVar, Union
6
6
 
7
7
  from rdflib.term import BNode, Literal, Node, URIRef
8
8
 
9
9
  from iolanta.models import NotLiteralNode, Triple, TripleTemplate
10
- from iolanta.stack import Stack
11
- from ldflex import LDFlex
12
- from ldflex.ldflex import QueryResult, SPARQLQueryArgument
10
+ from iolanta.query_result import QueryResult, SPARQLQueryArgument
13
11
 
14
12
  FacetOutput = TypeVar('FacetOutput')
15
13
 
@@ -21,18 +19,12 @@ class Facet(Generic[FacetOutput]):
21
19
  iri: NotLiteralNode
22
20
  iolanta: 'iolanta.Iolanta' = field(repr=False)
23
21
  as_datatype: Optional[NotLiteralNode] = None
24
- stack_children: List[Stack] = field(default_factory=list, repr=False)
25
22
 
26
23
  @property
27
24
  def stored_queries_path(self) -> Path:
28
25
  """Construct directory for stored queries for this facet."""
29
26
  return Path(inspect.getfile(self.__class__)).parent / 'sparql'
30
27
 
31
- @property
32
- def ldflex(self) -> LDFlex:
33
- """Extract LDFLex instance."""
34
- return self.iolanta.ldflex
35
-
36
28
  @cached_property
37
29
  def uriref(self) -> NotLiteralNode:
38
30
  """Format as URIRef."""
@@ -47,7 +39,7 @@ class Facet(Generic[FacetOutput]):
47
39
  **kwargs: SPARQLQueryArgument,
48
40
  ) -> QueryResult:
49
41
  """SPARQL query."""
50
- return self.ldflex.query(
42
+ return self.iolanta.query(
51
43
  query_text=query_text,
52
44
  **kwargs,
53
45
  )
@@ -58,15 +50,11 @@ class Facet(Generic[FacetOutput]):
58
50
  as_datatype: NotLiteralNode,
59
51
  ) -> Any:
60
52
  """Shortcut to render something via iolanta."""
61
- rendered, stack = self.iolanta.render(
53
+ return self.iolanta.render(
62
54
  node=node,
63
55
  as_datatype=as_datatype,
64
56
  )
65
57
 
66
- self.stack_children.append(stack)
67
-
68
- return rendered
69
-
70
58
  def render_all(
71
59
  self,
72
60
  node: Node,
@@ -92,19 +80,6 @@ class Facet(Generic[FacetOutput]):
92
80
  """Preferred language for Iolanta output."""
93
81
  return self.iolanta.language
94
82
 
95
- @property
96
- def stack(self):
97
- """
98
- Return stack.
99
-
100
- FIXME: I have no idea. Maybe delete this nonsense.
101
- """
102
- return Stack(
103
- node=self.iri,
104
- facet=self,
105
- children=self.stack_children,
106
- )
107
-
108
83
  def find_triple(
109
84
  self,
110
85
  triple: TripleTemplate,
@@ -29,7 +29,7 @@ class PageTitle(IolantaWidgetMixin, Static):
29
29
  return self.iolanta.render(
30
30
  self.iri,
31
31
  as_datatype=DATATYPES.title,
32
- )[0]
32
+ )
33
33
 
34
34
  def on_mount(self):
35
35
  """Initialize rendering of a title."""
@@ -131,7 +131,7 @@ class PageSwitcher(IolantaWidgetMixin, ContentSwitcher): # noqa: WPS214
131
131
  self.iolanta.render,
132
132
  facet,
133
133
  as_datatype=DATATYPES.title,
134
- )[0],
134
+ ),
135
135
  )
136
136
  for facet in other_facets
137
137
  ]
@@ -103,7 +103,7 @@ class InstancesList(ListView): # noqa: WPS214
103
103
  self.app.iolanta.render(
104
104
  instance_item.node,
105
105
  as_datatype=DATATYPES.title,
106
- )[0],
106
+ ),
107
107
  )
108
108
 
109
109
  def stream_instance_items_chunk(
@@ -60,7 +60,7 @@ class PropertyName(Widget, can_focus=True, inherit_bindings=False):
60
60
 
61
61
  def render_title(self):
62
62
  """Render title in a separate thread."""
63
- return self.app.iolanta.render(self.iri, DATATYPES.title)[0]
63
+ return self.app.iolanta.render(self.iri, DATATYPES.title)
64
64
 
65
65
  def render(self) -> RenderResult:
66
66
  """Render node title."""
@@ -202,7 +202,7 @@ class PropertiesContainer(Vertical):
202
202
  widget.renderable = self.app.iolanta.render(
203
203
  widget.iri,
204
204
  as_datatype=DATATYPES.title,
205
- )[0]
205
+ )
206
206
 
207
207
  def on_mount(self):
208
208
  """Initiate rendering in the background."""
@@ -22,7 +22,7 @@ class GraphFacet(Facet[Widget]):
22
22
  triples_view = self.iolanta.render(
23
23
  self.iri,
24
24
  as_datatype=DATATYPES['textual-graph-triples'],
25
- )[0]
25
+ )
26
26
 
27
27
  return VerticalScroll(
28
28
  PageTitle(self.iri, extra=f'({triple_count} triples)'),
@@ -121,7 +121,7 @@ class TriplesView(IolantaWidgetMixin, Vertical):
121
121
  term_view.renderable = self.iolanta.render(
122
122
  term_view.uri,
123
123
  as_datatype=term_view.as_datatype,
124
- )[0]
124
+ )
125
125
 
126
126
 
127
127
  class GraphTriplesFacet(Facet[Widget]):
@@ -61,7 +61,7 @@ class NanopublicationScreen(IolantaWidgetMixin, VerticalScroll):
61
61
  yield self.iolanta.render(
62
62
  row['assertion'],
63
63
  as_datatype=DATATYPES['textual-graph-triples'],
64
- )[0]
64
+ )
65
65
 
66
66
  provenance = []
67
67
  if row.get('author'):
@@ -36,4 +36,4 @@ class TermList(IolantaWidgetMixin, Horizontal):
36
36
  child.renderable = self.iolanta.render(
37
37
  child.uri,
38
38
  as_datatype=child.as_datatype,
39
- )[0]
39
+ )
@@ -18,8 +18,10 @@ from typing import ( # noqa: WPS235
18
18
  import funcy
19
19
  import loguru
20
20
  import yaml_ld
21
- from rdflib import ConjunctiveGraph, Literal, Namespace, URIRef
21
+ from pyparsing import ParseException
22
+ from rdflib import ConjunctiveGraph, Graph, Literal, Namespace, URIRef
22
23
  from rdflib.namespace import NamespaceManager
24
+ from rdflib.plugins.sparql.processor import SPARQLResult
23
25
  from rdflib.term import Node
24
26
  from yaml_ld.document_loaders.content_types import ParserNotFound
25
27
  from yaml_ld.errors import YAMLLDError
@@ -44,9 +46,13 @@ from iolanta.node_to_qname import node_to_qname
44
46
  from iolanta.parse_quads import parse_quads
45
47
  from iolanta.parsers.yaml import YAML
46
48
  from iolanta.plugin import Plugin
49
+ from iolanta.query_result import (
50
+ QueryResult,
51
+ SPARQLParseException,
52
+ SPARQLQueryArgument,
53
+ format_query_bindings,
54
+ )
47
55
  from iolanta.resolvers.python_import import PythonImportResolver
48
- from iolanta.stack import Stack
49
- from ldflex import LDFlex
50
56
 
51
57
 
52
58
  class LoggerProtocol(Protocol):
@@ -125,14 +131,56 @@ class Iolanta: # noqa: WPS214
125
131
  for plugin_class in self.plugin_classes
126
132
  ]
127
133
 
128
- @property
129
- def ldflex(self) -> LDFlex:
134
+ def query(
135
+ self,
136
+ query_text: str,
137
+ **kwargs: SPARQLQueryArgument,
138
+ ) -> QueryResult:
130
139
  """
131
- Create ldflex instance.
140
+ Run a SPARQL `SELECT`, `CONSTRUCT`, or `ASK` query.
132
141
 
133
- FIXME: Get rid of it.
142
+ Args:
143
+ query_text: The SPARQL text;
144
+ **kwargs: bind variables in the query to values if necessary. For
145
+ example:
146
+
147
+ ```python
148
+ iolanta.query(
149
+ 'SELECT ?title WHERE { ?page rdfs:label ?title }',
150
+ ?page=page_iri,
151
+ )
152
+ ```
153
+
154
+ Returns:
155
+ Results of the query:
156
+
157
+ - a graph for `CONSTRUCT`,
158
+ - a list of dicts for `SELECT`,
159
+ - or a boolean for `ASK`.
134
160
  """
135
- return LDFlex(self.graph)
161
+ try:
162
+ sparql_result: SPARQLResult = self.graph.query(
163
+ query_text,
164
+ processor='cyberspace',
165
+ initBindings=kwargs,
166
+ )
167
+ except ParseException as err:
168
+ raise SPARQLParseException(
169
+ error=err,
170
+ query=query_text,
171
+ ) from err
172
+
173
+ if sparql_result.askAnswer is not None:
174
+ return sparql_result.askAnswer
175
+
176
+ if sparql_result.graph is not None:
177
+ graph: Graph = sparql_result.graph
178
+ for prefix, namespace in self.graph.namespaces():
179
+ graph.bind(prefix, namespace)
180
+
181
+ return graph
182
+
183
+ return format_query_bindings(sparql_result.bindings)
136
184
 
137
185
  @functools.cached_property
138
186
  def namespaces_to_bind(self) -> Dict[str, Namespace]:
@@ -254,12 +302,6 @@ class Iolanta: # noqa: WPS214
254
302
  self.graph.bind(prefix='dcterms', namespace=namespaces.DCTERMS)
255
303
  self.graph.bind(prefix='rdfg', namespace=namespaces.RDFG)
256
304
 
257
- @property
258
- def query(self):
259
- """Make a SPARQL query."""
260
- self.maybe_infer()
261
- return self.ldflex.query
262
-
263
305
  @functools.cached_property
264
306
  def context_paths(self) -> Iterable[Path]:
265
307
  """
@@ -318,7 +360,7 @@ class Iolanta: # noqa: WPS214
318
360
  self,
319
361
  node: Node,
320
362
  as_datatype: NotLiteralNode,
321
- ) -> Tuple[Any, Stack]:
363
+ ) -> Any:
322
364
  """Find an Iolanta facet for a node and render it."""
323
365
  node = normalize_term(node)
324
366
 
@@ -345,7 +387,7 @@ class Iolanta: # noqa: WPS214
345
387
  )
346
388
 
347
389
  try:
348
- return facet.show(), facet.stack
390
+ return facet.show()
349
391
 
350
392
  except Exception as err:
351
393
  raise FacetError(
@@ -0,0 +1,73 @@
1
+ from dataclasses import dataclass
2
+ from typing import Dict, List, Mapping, Optional, Union
3
+
4
+ from documented import DocumentedError
5
+ from frozendict import frozendict
6
+ from pyparsing import ParseException
7
+ from rdflib import Graph
8
+ from rdflib.term import Identifier, Node, Variable
9
+
10
+ SelectRow = Mapping[str, Node]
11
+
12
+
13
+ class SelectResult(List[SelectRow]):
14
+ """Result of a SPARQL SELECT."""
15
+
16
+ @property
17
+ def first(self) -> Optional[SelectRow]:
18
+ """Return first element of the list."""
19
+ return self[0] if self else None
20
+
21
+
22
+ SPARQLQueryArgument = Optional[Union[Node, str, int, float]]
23
+
24
+
25
+ QueryResult = Union[
26
+ SelectResult, # SELECT
27
+ Graph, # CONSTRUCT
28
+ bool, # ASK
29
+ ]
30
+
31
+
32
+ def format_query_bindings(
33
+ bindings: List[Dict[Variable, Identifier]],
34
+ ) -> SelectResult:
35
+ """
36
+ Format bindings before returning them.
37
+
38
+ Converts Variable to str for ease of addressing.
39
+ """
40
+ return SelectResult([
41
+ frozendict({
42
+ str(variable_name): rdf_value
43
+ for variable_name, rdf_value # noqa: WPS361
44
+ in row.items()
45
+ })
46
+ for row in bindings
47
+ ])
48
+
49
+
50
+ @dataclass
51
+ class SPARQLParseException(DocumentedError):
52
+ """
53
+ SPARQL query is invalid.
54
+
55
+ Error:
56
+
57
+ ```
58
+ {self.error}
59
+ ```
60
+
61
+ Query:
62
+ ```sparql hl_lines="{self.highlight_code}"
63
+ {self.query}
64
+ ```
65
+ """ # noqa: D412
66
+
67
+ error: ParseException
68
+ query: str
69
+
70
+ @property
71
+ def highlight_code(self):
72
+ """Define lines to highlight."""
73
+ return self.error.lineno
@@ -1,16 +1,11 @@
1
1
  [tool.poetry]
2
2
  name = "iolanta"
3
- version = "1.2.11"
3
+ version = "2.0.1"
4
4
  description = "Semantic Web browser"
5
5
  authors = ["Anatoly Scherbakov <altaisoft@gmail.com>"]
6
6
  license = "MIT"
7
7
  readme = "README.md"
8
8
 
9
- packages = [
10
- { include = "ldflex" },
11
- { include = "iolanta" },
12
- ]
13
-
14
9
  [tool.poetry.dependencies]
15
10
  python = ">=3.10,<4.0"
16
11
  rdflib = "<8.0"
@@ -26,7 +21,6 @@ owlrl = ">=6.0.2"
26
21
  funcy = ">=2.0"
27
22
  rich = ">=13.3.1"
28
23
  textual = ">=0.83.0"
29
- iolanta-tables = {version = "^0.1.7", optional = true}
30
24
  yarl = ">=1.9.4"
31
25
  boltons = ">=24.0.0"
32
26
  yaml-ld = ">=1.1.7"
@@ -1,11 +0,0 @@
1
- from dataclasses import dataclass, field
2
- from typing import List
3
-
4
- from rdflib.term import Node
5
-
6
-
7
- @dataclass
8
- class Stack:
9
- node: Node
10
- facet: 'iolanta.facets.facet.Facet'
11
- children: List['Stack'] = field(default_factory=list)
@@ -1 +0,0 @@
1
- from ldflex.ldflex import LDFlex
@@ -1,138 +0,0 @@
1
- from dataclasses import dataclass
2
- from typing import Dict, List, Mapping, Optional, Union
3
-
4
- from documented import DocumentedError
5
- from frozendict import frozendict
6
- from pyparsing import ParseException
7
- from rdflib import Graph
8
- from rdflib.plugins.sparql.processor import SPARQLResult
9
- from rdflib.term import Identifier, Node, Variable
10
-
11
- from iolanta.cyberspace.processor import GlobalSPARQLProcessor
12
-
13
- SelectRow = Mapping[str, Node]
14
-
15
-
16
- class SelectResult(List[SelectRow]):
17
- """Result of a SPARQL SELECT."""
18
-
19
- @property
20
- def first(self) -> Optional[SelectRow]:
21
- """Return first element of the list."""
22
- return self[0] if self else None
23
-
24
-
25
- SPARQLQueryArgument = Optional[Union[Node, str, int, float]]
26
-
27
-
28
- QueryResult = Union[
29
- SelectResult, # SELECT
30
- Graph, # CONSTRUCT
31
- bool, # ASK
32
- ]
33
-
34
-
35
- def _format_query_bindings(
36
- bindings: List[Dict[Variable, Identifier]],
37
- ) -> SelectResult:
38
- """
39
- Format bindings before returning them.
40
-
41
- Converts Variable to str for ease of addressing.
42
- """
43
- return SelectResult([
44
- frozendict({
45
- str(variable_name): rdf_value
46
- for variable_name, rdf_value
47
- in row.items()
48
- })
49
- for row in bindings
50
- ])
51
-
52
-
53
- @dataclass
54
- class SPARQLParseException(DocumentedError):
55
- """
56
- SPARQL query is invalid.
57
-
58
- Error:
59
-
60
- ```
61
- {self.error}
62
- ```
63
-
64
- Query:
65
- ```sparql hl_lines="{self.highlight_code}"
66
- {self.query}
67
- ```
68
- """
69
-
70
- error: ParseException
71
- query: str
72
-
73
- @property
74
- def highlight_code(self):
75
- """Define lines to highlight."""
76
- return self.error.lineno
77
-
78
-
79
- @dataclass
80
- class LDFlex:
81
- """Fluent interface to a semantic graph."""
82
-
83
- graph: Graph
84
-
85
- def query(
86
- self,
87
- query_text: str,
88
- **kwargs: SPARQLQueryArgument,
89
- ) -> QueryResult:
90
- """
91
- Run a SPARQL `SELECT`, `CONSTRUCT`, or `ASK` query.
92
-
93
- Args:
94
- query_text: The SPARQL text;
95
- **kwargs: bind variables in the query to values if necessary. For
96
- example:
97
-
98
- ```python
99
- ldflex.query(
100
- 'SELECT ?title WHERE { ?page rdfs:label ?title }',
101
- ?page=page_iri,
102
- )
103
- ```
104
-
105
- Returns:
106
- Results of the query:
107
-
108
- - a graph for `CONSTRUCT`,
109
- - a list of dicts for `SELECT`,
110
- - or a boolean for `ASK`.
111
- """
112
- try:
113
- sparql_result: SPARQLResult = self.graph.query(
114
- query_text,
115
- processor='cyberspace',
116
- initBindings=kwargs,
117
- )
118
- except ParseException as err:
119
- raise SPARQLParseException(
120
- error=err,
121
- query=query_text,
122
- ) from err
123
-
124
- if sparql_result.askAnswer is not None:
125
- return sparql_result.askAnswer
126
-
127
- if sparql_result.graph is not None:
128
- graph: Graph = sparql_result.graph
129
- for prefix, namespace in self.graph.namespaces():
130
- graph.bind(prefix, namespace)
131
-
132
- return graph
133
-
134
- return _format_query_bindings(sparql_result.bindings)
135
-
136
- def update(self, sparql_query: str):
137
- """Apply the given SPARQL INSERT query."""
138
- self.graph.update(sparql_query)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes