snapquery 0.2.2__tar.gz → 0.2.3__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.
- snapquery-0.2.3/CITATION.cff +49 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/PKG-INFO +23 -27
- {snapquery-0.2.2 → snapquery-0.2.3}/README.md +22 -26
- {snapquery-0.2.2 → snapquery-0.2.3}/pyproject.toml +1 -0
- snapquery-0.2.3/scripts/test_queries +214 -0
- snapquery-0.2.3/snapquery/__init__.py +1 -0
- snapquery-0.2.3/snapquery/query_set_cmd.py +168 -0
- snapquery-0.2.3/snapquery/query_set_tool.py +214 -0
- snapquery-0.2.2/snapquery/qimport_view.py → snapquery-0.2.3/snapquery/query_set_tool_view.py +3 -3
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/ceur-ws.yaml +610 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/dblp.yaml +101 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/federated-query-examples.yaml +291 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/orkg.yaml +40 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/qlever.yaml +3724 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/qlever_performance.yaml +100 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/scholia.yaml +8952 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/snapquery.yaml +26 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/wikidata-WikidataThesisToolkit.yaml +422 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/wikidata-WikidataThesisToolkitAlt.yaml +472 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/wikidata-examples.yaml +6751 -0
- snapquery-0.2.3/snapquery/samples/query-sets/yaml/wikidata-short-urls.yaml +1868 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/snapquery_cmd.py +2 -2
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/snapquery_webserver.py +3 -3
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/version.py +1 -1
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery.puml +3 -1
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_query_name.py +2 -2
- snapquery-0.2.3/tests/test_query_set_tool.py +152 -0
- snapquery-0.2.2/scripts/test_queries +0 -75
- snapquery-0.2.2/snapquery/__init__.py +0 -1
- snapquery-0.2.2/snapquery/qimport.py +0 -117
- snapquery-0.2.2/tests/test_import.py +0 -86
- {snapquery-0.2.2 → snapquery-0.2.3}/.github/workflows/build.yml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/.github/workflows/upload-to-pypi.yml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/.gitignore +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/.project +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/.pydevproject +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/LICENSE +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/docs/index.md +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/mkdocs.yml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/scripts/blackisort +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/scripts/doc +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/scripts/fixdomain +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/scripts/install +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/scripts/qlv +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/scripts/release +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/scripts/restore_db +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/scripts/test +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/authorization.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/basequeryview.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/ceurws.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/dblp.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/error_filter.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/execution.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/github_access.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/graph.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/models/__init__.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/models/person.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/models/sparql_components.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/mwlogin.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/namespace_stats_view.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/orcid.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/params_view.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/person_selector.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/pid.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/pid_lookup.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/prefix_merger.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/qlever.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/query_annotate.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/query_selector.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/resources/sparql_language.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/WikiProject_LSEThesisProject.wiki +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/ceur-ws.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/dblp.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/endpoints.yaml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/endpoints_optional.yaml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/federated-query-examples.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/graphs.yaml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/meta_query.yaml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/orkg.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/qlever.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/qlever_performance.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/query_stats.yaml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/scholia.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/snapquery.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/wikidata-WikidataThesisToolkit.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/wikidata-WikidataThesisToolkitAlt.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/wikidata-examples.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/samples/wikidata-short-urls.json +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/scholia.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/sib_sparql_examples.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/snapquery_core.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/snapquery_view.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/sparql_analyzer.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/stats_view.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/wd_page_query_extractor.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery/wd_short_url.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/snapquery.yaml +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/__init__.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/action_stats.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/query_extractors/__init__.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/query_extractors/sparql_standard_queries.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/qlever/ask_unsupported.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/qlever/invalid_literal.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/qlever/invalid_regex_func.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/qlever/memory_limit.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/qlever/timeout.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/triplydb/parser_error.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/wdqs/duplicate_prefix.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/wdqs/invalid_iri_declaration.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/wdqs/invalid_sparql_syntax.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/wdqs/timeout.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/resources/error_messages/wdqs/undefined_prefix.txt +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_authorization.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_ceurws.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_cmdline.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_endpoints.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_error_filter.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_graph.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_namedqueries.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_oauth.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_orcid.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_pids.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_prefix_merger.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_qlever.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_query_annotate.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_query_execution.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_restful_api.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_scholia.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_scholia_q.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_sib_examples.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_sparql_analyzer.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_sparql_components.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_wd_query_parsing.py +0 -0
- {snapquery-0.2.2 → snapquery-0.2.3}/tests/test_wd_short_url.py +0 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# CITATION.cff for https://github.com/WolfgangFahl/snapquery
|
|
2
|
+
# This CITATION.cff file was initially generated with cffinit.
|
|
3
|
+
# Visit https://bit.ly/cffinit to generate yours today!
|
|
4
|
+
cff-version: 1.2.0
|
|
5
|
+
title: SnapQuery
|
|
6
|
+
message: >-
|
|
7
|
+
If you use this software, please cite it using the
|
|
8
|
+
metadata from this file.
|
|
9
|
+
type: software
|
|
10
|
+
authors:
|
|
11
|
+
- given-names: Wolfgang
|
|
12
|
+
family-names: Fahl
|
|
13
|
+
affiliation: BITPlan GmbH
|
|
14
|
+
orcid: 'https://orcid.org/0000-0002-0821-6995'
|
|
15
|
+
- given-names: Tim
|
|
16
|
+
family-names: Holzheim
|
|
17
|
+
orcid: 'https://orcid.org/0000-0003-2533-6363'
|
|
18
|
+
- given-names: "Charles Tapley"
|
|
19
|
+
family-names: Hoyt
|
|
20
|
+
orcid: 'https://orcid.org/0000-0003-4423-4370'
|
|
21
|
+
- given-names: Dennis
|
|
22
|
+
family-names: Priskorn
|
|
23
|
+
orcid: 'https://orcid.org/0000-0002-7669-8498'
|
|
24
|
+
- given-names: Egon
|
|
25
|
+
family-names: Willighagen
|
|
26
|
+
orcid: 'https://orcid.org/0000-0001-7542-0286'
|
|
27
|
+
# - given-names: Wouter
|
|
28
|
+
# family-names: Beek
|
|
29
|
+
# orcid: 'https://orcid.org/0000-0003-0250-9655'
|
|
30
|
+
identifiers:
|
|
31
|
+
- type: doi
|
|
32
|
+
value: 10.5281/zenodo.17802425
|
|
33
|
+
repository-code: 'https://github.com/WolfgangFahl/snapquery'
|
|
34
|
+
url: 'https://snapquery.bitplan.com'
|
|
35
|
+
abstract: >-
|
|
36
|
+
FAIR Management of Query Sets to Mitigate Query Rot in
|
|
37
|
+
Knowledge Graphs
|
|
38
|
+
keywords:
|
|
39
|
+
- SPARQL
|
|
40
|
+
- Query Rot
|
|
41
|
+
- Knowledge Graph Management
|
|
42
|
+
- Benchmarking
|
|
43
|
+
- Refactoring
|
|
44
|
+
- Middleware
|
|
45
|
+
- Query Set
|
|
46
|
+
- FAIR
|
|
47
|
+
license: Apache-2.0
|
|
48
|
+
version: v0.2.2
|
|
49
|
+
date-released: '2025-12-03'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: snapquery
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Just Query wikidata and other SPARQL endpoints by query name - a frontend to Introduce Named Queries and Named Query Middleware to wikidata and other SPARQL endpoints
|
|
5
5
|
Project-URL: Home, https://github.com/WolfgangFahl/snapquery
|
|
6
6
|
Project-URL: Documentation, https://wiki.bitplan.com/index.php/snapquery
|
|
@@ -44,26 +44,30 @@ Requires-Dist: green; extra == 'test'
|
|
|
44
44
|
Description-Content-Type: text/markdown
|
|
45
45
|
|
|
46
46
|
# snapQuery
|
|
47
|
-
Just query
|
|
47
|
+
Just query by name of query ...
|
|
48
48
|
<pre>snapquery cats</pre> is all you need
|
|
49
49
|
|
|
50
|
-
This endpoint and query detail independent style of querying wikidata and
|
|
51
|
-
makes your queries future proof. No worries about blazegraph being replaced, the graph being split or timeouts haunting you.
|
|
50
|
+
This endpoint and query detail independent style of querying wikidata and similar knowledge graph services
|
|
51
|
+
makes your queries future proof. No worries about blazegraph being replaced, the graph being split or timeouts haunting you.
|
|
52
|
+
snapquery introduces named queries and named query middleware to wikidata and other knowledge graph endpoints.
|
|
52
53
|
|
|
53
|
-
snapquery is a tool that simplifies the process of previewing, annotating, rating, commenting, running, and exploring
|
|
54
|
-
queries across different
|
|
54
|
+
snapquery is a tool that simplifies the process of previewing, annotating, rating, commenting, running, and exploring
|
|
55
|
+
queries across different backends. It enhances user experience by storing query results and allowing easy
|
|
55
56
|
comparison across various backends and over time.
|
|
56
57
|
|
|
57
58
|
This tool is designed to assist users in curating and collaborating on queries, ensuring their continued functionality
|
|
58
59
|
over time. Developers and data consumers can access data conveniently through APIs, streamlining their workflow.
|
|
59
60
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
| **PyPi** | [](https://pypi.python.org/pypi/snapquery/) [](https://www.apache.org/licenses/LICENSE-2.0) [](https://pypi.org/project/snapquery/) [](https://pypi.org/project/snapquery/) [](https://pypi.org/project/snapquery/) |
|
|
63
|
-
| **GitHub** | [](https://github.com/WolfgangFahl/snapquery/actions/workflows/build.yml) [](https://github.com/WolfgangFahl/snapquery/releases) [](https://github.com/WolfgangFahl/snapquery/graphs/contributors) [](https://github.com/WolfgangFahl/snapquery/commits/) [](https://github.com/WolfgangFahl/snapquery/issues) [](https://github.com/WolfgangFahl/snapquery/issues/?q=is%3Aissue+is%3Aclosed) |
|
|
64
|
-
| **Code** | [](https://github.com/psf/black) [](https://pycqa.github.io/isort/) |
|
|
65
|
-
| **Docs** | [](https://WolfgangFahl.github.io/snapquery/) [](https://github.com/PyCQA/docformatter) [](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings) |
|
|
61
|
+
The technology behind the backend knowlede graphs such as RDF, SPARQL, SQL, CSV, APIs is hidden.
|
|
62
|
+
|
|
66
63
|
|
|
64
|
+
| | |
|
|
65
|
+
| :--- | :--- |
|
|
66
|
+
| **PyPi** | [](https://pypi.python.org/pypi/snapquery/) [](https://www.apache.org/licenses/LICENSE-2.0) [](https://pypi.org/project/snapquery/) [](https://pypi.org/project/snapquery/) [](https://pypi.org/project/snapquery/) |
|
|
67
|
+
| **GitHub** | [](https://github.com/WolfgangFahl/snapquery/actions/workflows/build.yml) [](https://github.com/WolfgangFahl/snapquery/releases) [](https://github.com/WolfgangFahl/snapquery/graphs/contributors) [](https://github.com/WolfgangFahl/snapquery/commits/) [](https://github.com/WolfgangFahl/snapquery/issues) [](https://github.com/WolfgangFahl/snapquery/issues/?q=is%3Aissue+is%3Aclosed) |
|
|
68
|
+
| **Code** | [](https://github.com/psf/black) [](https://pycqa.github.io/isort/) |
|
|
69
|
+
| **Docs** | [](https://WolfgangFahl.github.io/snapquery/) [](https://github.com/PyCQA/docformatter) [](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings) |
|
|
70
|
+
[](https://doi.org/10.5281/zenodo.17802424)
|
|
67
71
|
[](https://github.com/WolfgangFahl/snapquery/discussions)
|
|
68
72
|
## Demos
|
|
69
73
|
|
|
@@ -121,25 +125,25 @@ These are the planned features
|
|
|
121
125
|
|
|
122
126
|
* support for naming queries ([#9][i9]) ✅
|
|
123
127
|
* support for sharing queries (unique identifier) ([#2][i2]) ✅
|
|
124
|
-
* query multiple backends simultaneously and repeatedly
|
|
125
|
-
* stores queries and adaptations needed for different backends
|
|
126
|
-
* support user login
|
|
128
|
+
* query multiple backends simultaneously and repeatedly ✅
|
|
129
|
+
* stores queries and adaptations needed for different backends ✅
|
|
130
|
+
* support user login ✅
|
|
127
131
|
* support for spam protection
|
|
128
132
|
* support for rating queries
|
|
129
133
|
* support for commenting on queries
|
|
130
|
-
* support for detecting when a query returns different results between different backends
|
|
131
|
-
* support for query states: reliable, needs investigation, need verification
|
|
134
|
+
* support for detecting when a query returns different results between different backends ✅
|
|
135
|
+
* support for query states: reliable, needs investigation, need verification ✅
|
|
132
136
|
* support for autodetecting when a query returns fewer results than before (change in underlying data/model in
|
|
133
137
|
Wikidata) -> needs investigation
|
|
134
138
|
* support for marking queries as reliable query by users
|
|
135
|
-
* support for seeing a state history per query
|
|
139
|
+
* support for seeing a state history per query ✅
|
|
136
140
|
* support for storing query results so you don’t have to wait
|
|
137
141
|
* support for adding metadata to queries
|
|
138
142
|
* add main subject (QID) to query
|
|
139
143
|
* author -> id of author in the system
|
|
140
144
|
* forked from x
|
|
141
145
|
* has REST API for data consumers e.g. LLM developers who want to present user-verified queries and data to users to
|
|
142
|
-
increase reliability
|
|
146
|
+
increase reliability ✅
|
|
143
147
|
|
|
144
148
|
## User stories
|
|
145
149
|
|
|
@@ -193,19 +197,11 @@ These are the planned features
|
|
|
193
197
|
|
|
194
198
|
[i10]: https://github.com/WolfgangFahl/snapquery/issues/10
|
|
195
199
|
[i9]: https://github.com/WolfgangFahl/snapquery/issues/9
|
|
196
|
-
|
|
197
200
|
[i8]: https://github.com/WolfgangFahl/snapquery/issues/8
|
|
198
|
-
|
|
199
201
|
[i7]: https://github.com/WolfgangFahl/snapquery/issues/7
|
|
200
|
-
|
|
201
202
|
[i6]: https://github.com/WolfgangFahl/snapquery/issues/6
|
|
202
|
-
|
|
203
203
|
[i5]: https://github.com/WolfgangFahl/snapquery/issues/5
|
|
204
|
-
|
|
205
204
|
[i4]: https://github.com/WolfgangFahl/snapquery/issues/4
|
|
206
|
-
|
|
207
205
|
[i3]: https://github.com/WolfgangFahl/snapquery/issues/3
|
|
208
|
-
|
|
209
206
|
[i2]: https://github.com/WolfgangFahl/snapquery/issues/2
|
|
210
|
-
|
|
211
207
|
[i1]: https://github.com/WolfgangFahl/snapquery/issues/1
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
# snapQuery
|
|
2
|
-
Just query
|
|
2
|
+
Just query by name of query ...
|
|
3
3
|
<pre>snapquery cats</pre> is all you need
|
|
4
4
|
|
|
5
|
-
This endpoint and query detail independent style of querying wikidata and
|
|
6
|
-
makes your queries future proof. No worries about blazegraph being replaced, the graph being split or timeouts haunting you.
|
|
5
|
+
This endpoint and query detail independent style of querying wikidata and similar knowledge graph services
|
|
6
|
+
makes your queries future proof. No worries about blazegraph being replaced, the graph being split or timeouts haunting you.
|
|
7
|
+
snapquery introduces named queries and named query middleware to wikidata and other knowledge graph endpoints.
|
|
7
8
|
|
|
8
|
-
snapquery is a tool that simplifies the process of previewing, annotating, rating, commenting, running, and exploring
|
|
9
|
-
queries across different
|
|
9
|
+
snapquery is a tool that simplifies the process of previewing, annotating, rating, commenting, running, and exploring
|
|
10
|
+
queries across different backends. It enhances user experience by storing query results and allowing easy
|
|
10
11
|
comparison across various backends and over time.
|
|
11
12
|
|
|
12
13
|
This tool is designed to assist users in curating and collaborating on queries, ensuring their continued functionality
|
|
13
14
|
over time. Developers and data consumers can access data conveniently through APIs, streamlining their workflow.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
| **PyPi** | [](https://pypi.python.org/pypi/snapquery/) [](https://www.apache.org/licenses/LICENSE-2.0) [](https://pypi.org/project/snapquery/) [](https://pypi.org/project/snapquery/) [](https://pypi.org/project/snapquery/) |
|
|
18
|
-
| **GitHub** | [](https://github.com/WolfgangFahl/snapquery/actions/workflows/build.yml) [](https://github.com/WolfgangFahl/snapquery/releases) [](https://github.com/WolfgangFahl/snapquery/graphs/contributors) [](https://github.com/WolfgangFahl/snapquery/commits/) [](https://github.com/WolfgangFahl/snapquery/issues) [](https://github.com/WolfgangFahl/snapquery/issues/?q=is%3Aissue+is%3Aclosed) |
|
|
19
|
-
| **Code** | [](https://github.com/psf/black) [](https://pycqa.github.io/isort/) |
|
|
20
|
-
| **Docs** | [](https://WolfgangFahl.github.io/snapquery/) [](https://github.com/PyCQA/docformatter) [](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings) |
|
|
16
|
+
The technology behind the backend knowlede graphs such as RDF, SPARQL, SQL, CSV, APIs is hidden.
|
|
17
|
+
|
|
21
18
|
|
|
19
|
+
| | |
|
|
20
|
+
| :--- | :--- |
|
|
21
|
+
| **PyPi** | [](https://pypi.python.org/pypi/snapquery/) [](https://www.apache.org/licenses/LICENSE-2.0) [](https://pypi.org/project/snapquery/) [](https://pypi.org/project/snapquery/) [](https://pypi.org/project/snapquery/) |
|
|
22
|
+
| **GitHub** | [](https://github.com/WolfgangFahl/snapquery/actions/workflows/build.yml) [](https://github.com/WolfgangFahl/snapquery/releases) [](https://github.com/WolfgangFahl/snapquery/graphs/contributors) [](https://github.com/WolfgangFahl/snapquery/commits/) [](https://github.com/WolfgangFahl/snapquery/issues) [](https://github.com/WolfgangFahl/snapquery/issues/?q=is%3Aissue+is%3Aclosed) |
|
|
23
|
+
| **Code** | [](https://github.com/psf/black) [](https://pycqa.github.io/isort/) |
|
|
24
|
+
| **Docs** | [](https://WolfgangFahl.github.io/snapquery/) [](https://github.com/PyCQA/docformatter) [](https://google.github.io/styleguide/pyguide.html#s3.8-comments-and-docstrings) |
|
|
25
|
+
[](https://doi.org/10.5281/zenodo.17802424)
|
|
22
26
|
[](https://github.com/WolfgangFahl/snapquery/discussions)
|
|
23
27
|
## Demos
|
|
24
28
|
|
|
@@ -76,25 +80,25 @@ These are the planned features
|
|
|
76
80
|
|
|
77
81
|
* support for naming queries ([#9][i9]) ✅
|
|
78
82
|
* support for sharing queries (unique identifier) ([#2][i2]) ✅
|
|
79
|
-
* query multiple backends simultaneously and repeatedly
|
|
80
|
-
* stores queries and adaptations needed for different backends
|
|
81
|
-
* support user login
|
|
83
|
+
* query multiple backends simultaneously and repeatedly ✅
|
|
84
|
+
* stores queries and adaptations needed for different backends ✅
|
|
85
|
+
* support user login ✅
|
|
82
86
|
* support for spam protection
|
|
83
87
|
* support for rating queries
|
|
84
88
|
* support for commenting on queries
|
|
85
|
-
* support for detecting when a query returns different results between different backends
|
|
86
|
-
* support for query states: reliable, needs investigation, need verification
|
|
89
|
+
* support for detecting when a query returns different results between different backends ✅
|
|
90
|
+
* support for query states: reliable, needs investigation, need verification ✅
|
|
87
91
|
* support for autodetecting when a query returns fewer results than before (change in underlying data/model in
|
|
88
92
|
Wikidata) -> needs investigation
|
|
89
93
|
* support for marking queries as reliable query by users
|
|
90
|
-
* support for seeing a state history per query
|
|
94
|
+
* support for seeing a state history per query ✅
|
|
91
95
|
* support for storing query results so you don’t have to wait
|
|
92
96
|
* support for adding metadata to queries
|
|
93
97
|
* add main subject (QID) to query
|
|
94
98
|
* author -> id of author in the system
|
|
95
99
|
* forked from x
|
|
96
100
|
* has REST API for data consumers e.g. LLM developers who want to present user-verified queries and data to users to
|
|
97
|
-
increase reliability
|
|
101
|
+
increase reliability ✅
|
|
98
102
|
|
|
99
103
|
## User stories
|
|
100
104
|
|
|
@@ -148,19 +152,11 @@ These are the planned features
|
|
|
148
152
|
|
|
149
153
|
[i10]: https://github.com/WolfgangFahl/snapquery/issues/10
|
|
150
154
|
[i9]: https://github.com/WolfgangFahl/snapquery/issues/9
|
|
151
|
-
|
|
152
155
|
[i8]: https://github.com/WolfgangFahl/snapquery/issues/8
|
|
153
|
-
|
|
154
156
|
[i7]: https://github.com/WolfgangFahl/snapquery/issues/7
|
|
155
|
-
|
|
156
157
|
[i6]: https://github.com/WolfgangFahl/snapquery/issues/6
|
|
157
|
-
|
|
158
158
|
[i5]: https://github.com/WolfgangFahl/snapquery/issues/5
|
|
159
|
-
|
|
160
159
|
[i4]: https://github.com/WolfgangFahl/snapquery/issues/4
|
|
161
|
-
|
|
162
160
|
[i3]: https://github.com/WolfgangFahl/snapquery/issues/3
|
|
163
|
-
|
|
164
161
|
[i2]: https://github.com/WolfgangFahl/snapquery/issues/2
|
|
165
|
-
|
|
166
162
|
[i1]: https://github.com/WolfgangFahl/snapquery/issues/1
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# WF 2024-06-05
|
|
3
|
+
# Enhanced script to handle snapquery calls efficiently and with feedback
|
|
4
|
+
|
|
5
|
+
# Function to execute snapquery in the background with feedback
|
|
6
|
+
run_snapquery() {
|
|
7
|
+
local domain="$1"
|
|
8
|
+
local namespace="$2"
|
|
9
|
+
local endpoint="$3"
|
|
10
|
+
# Sanitize the namespace to be filesystem-friendly
|
|
11
|
+
local sanitized_namespace="${namespace//\//-}" # Replace slashes with hyphens
|
|
12
|
+
sanitized_namespace="${sanitized_namespace//[^a-zA-Z0-9-_]/_}" # Replace any non-alphanumeric characters with underscores
|
|
13
|
+
# Ensure the log directory exists
|
|
14
|
+
local log_dir="/tmp/query_test_log"
|
|
15
|
+
mkdir -p "$log_dir"
|
|
16
|
+
local log="${log_dir}/${endpoint}-${sanitized_namespace}@${domain}.log"
|
|
17
|
+
local command="snapquery -d -tq --progress -en '$endpoint' --context 'cmd_line_tests' --domain '$domain' --namespace '$namespace'"
|
|
18
|
+
echo "Running $command..."
|
|
19
|
+
nohup bash -c "$command" 2>&1 > "$log" &
|
|
20
|
+
echo "... logged at $log"
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
# Function to determine which endpoints to use based on the domain
|
|
24
|
+
select_endpoints() {
|
|
25
|
+
local domain="$1"
|
|
26
|
+
local namespace="$2"
|
|
27
|
+
|
|
28
|
+
case "$domain" in
|
|
29
|
+
dblp.org)
|
|
30
|
+
echo "dblp"
|
|
31
|
+
;;
|
|
32
|
+
orkg.org)
|
|
33
|
+
echo "wikidata" # ORKG data might work with Wikidata endpoints
|
|
34
|
+
;;
|
|
35
|
+
wikidata.org)
|
|
36
|
+
echo "wikidata wikidata-main wikidata-scholarly wikidata-dbis wikidata-qlever"
|
|
37
|
+
;;
|
|
38
|
+
ceur-ws.org)
|
|
39
|
+
echo "wikidata" # CEUR-WS queries likely target Wikidata
|
|
40
|
+
;;
|
|
41
|
+
scholia.toolforge.org)
|
|
42
|
+
echo "wikidata wikidata-scholarly" # Scholia is Wikidata-focused
|
|
43
|
+
;;
|
|
44
|
+
bitplan.com)
|
|
45
|
+
echo "wikidata wikidata-qlever"
|
|
46
|
+
;;
|
|
47
|
+
qlever.cs.uni-freiburg.de)
|
|
48
|
+
case "$namespace" in
|
|
49
|
+
performance-dblp)
|
|
50
|
+
echo "dblp"
|
|
51
|
+
;;
|
|
52
|
+
issues.wikidata)
|
|
53
|
+
echo "wikidata-qlever wikidata-qlever-dbis"
|
|
54
|
+
;;
|
|
55
|
+
*)
|
|
56
|
+
echo "wikidata-qlever wikidata-qlever-dbis"
|
|
57
|
+
;;
|
|
58
|
+
esac
|
|
59
|
+
;;
|
|
60
|
+
genealogy.net)
|
|
61
|
+
echo "gov"
|
|
62
|
+
;;
|
|
63
|
+
*)
|
|
64
|
+
# Default fallback - use basic Wikidata endpoints
|
|
65
|
+
echo "wikidata"
|
|
66
|
+
;;
|
|
67
|
+
esac
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# Function to loop over selected endpoints and execute queries
|
|
71
|
+
execute_queries() {
|
|
72
|
+
local domain="$1"
|
|
73
|
+
local namespace="$2"
|
|
74
|
+
local endpoints=$(select_endpoints "$domain" "$namespace")
|
|
75
|
+
IFS=' ' read -ra endpoint_array <<< "$endpoints"
|
|
76
|
+
for endpoint in "${endpoint_array[@]}"; do
|
|
77
|
+
run_snapquery "$domain" "$namespace" "$endpoint"
|
|
78
|
+
done
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
# Function to check if an endpoint is available
|
|
82
|
+
check_endpoint() {
|
|
83
|
+
local endpoint="$1"
|
|
84
|
+
local available_endpoints=$(snapquery -le | cut -d':' -f1)
|
|
85
|
+
if echo "$available_endpoints" | grep -q "^$endpoint$"; then
|
|
86
|
+
return 0
|
|
87
|
+
else
|
|
88
|
+
return 1
|
|
89
|
+
fi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# Function to filter available endpoints
|
|
93
|
+
filter_available_endpoints() {
|
|
94
|
+
local endpoints="$1"
|
|
95
|
+
local available=""
|
|
96
|
+
IFS=' ' read -ra endpoint_array <<< "$endpoints"
|
|
97
|
+
for endpoint in "${endpoint_array[@]}"; do
|
|
98
|
+
if check_endpoint "$endpoint"; then
|
|
99
|
+
available="$available $endpoint"
|
|
100
|
+
else
|
|
101
|
+
echo "Warning: Endpoint '$endpoint' not available, skipping..."
|
|
102
|
+
fi
|
|
103
|
+
done
|
|
104
|
+
echo "$available" | sed 's/^ *//' # Remove leading space
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# Enhanced execute_queries function with endpoint validation
|
|
108
|
+
execute_queries_safe() {
|
|
109
|
+
local domain="$1"
|
|
110
|
+
local namespace="$2"
|
|
111
|
+
local selected_endpoints=$(select_endpoints "$domain" "$namespace")
|
|
112
|
+
local available_endpoints=$(filter_available_endpoints "$selected_endpoints")
|
|
113
|
+
|
|
114
|
+
if [ -z "$available_endpoints" ]; then
|
|
115
|
+
echo "No available endpoints for $domain/$namespace"
|
|
116
|
+
return 1
|
|
117
|
+
fi
|
|
118
|
+
|
|
119
|
+
IFS=' ' read -ra endpoint_array <<< "$available_endpoints"
|
|
120
|
+
for endpoint in "${endpoint_array[@]}"; do
|
|
121
|
+
run_snapquery "$domain" "$namespace" "$endpoint"
|
|
122
|
+
done
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
# Main function to process namespace data
|
|
126
|
+
process_namespace_data() {
|
|
127
|
+
local namespace_data=$(snapquery -ln) # Fetch namespaces and their totals dynamically
|
|
128
|
+
|
|
129
|
+
while IFS=':' read -r full_namespace count; do
|
|
130
|
+
local namespace="${full_namespace%%@*}"
|
|
131
|
+
local domain="${full_namespace#*@}"
|
|
132
|
+
echo "Processing $domain/$namespace with total entries $count"
|
|
133
|
+
execute_queries_safe "$domain" "$namespace"
|
|
134
|
+
done <<< "$namespace_data"
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
# Function to show available endpoints
|
|
138
|
+
show_available_endpoints() {
|
|
139
|
+
echo "Available endpoints:"
|
|
140
|
+
snapquery -le | while IFS=':' read -r name url sparql_url method; do
|
|
141
|
+
echo " $name: $url -> $sparql_url ($method)"
|
|
142
|
+
done
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
# Function to show usage
|
|
146
|
+
show_usage() {
|
|
147
|
+
cat << EOF
|
|
148
|
+
Usage: $0 [OPTIONS]
|
|
149
|
+
|
|
150
|
+
Options:
|
|
151
|
+
-h, --help Show this help message
|
|
152
|
+
-e, --endpoints Show available endpoints
|
|
153
|
+
-d, --dry-run Show what would be executed without running
|
|
154
|
+
-n, --namespace NS Process only specific namespace
|
|
155
|
+
|
|
156
|
+
Examples:
|
|
157
|
+
$0 # Process all namespaces
|
|
158
|
+
$0 -e # Show available endpoints
|
|
159
|
+
$0 -n examples@wikidata.org # Process only specific namespace
|
|
160
|
+
EOF
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
# Parse command line arguments
|
|
164
|
+
DRY_RUN=false
|
|
165
|
+
SPECIFIC_NAMESPACE=""
|
|
166
|
+
|
|
167
|
+
while [[ $# -gt 0 ]]; do
|
|
168
|
+
case $1 in
|
|
169
|
+
-h|--help)
|
|
170
|
+
show_usage
|
|
171
|
+
exit 0
|
|
172
|
+
;;
|
|
173
|
+
-e|--endpoints)
|
|
174
|
+
show_available_endpoints
|
|
175
|
+
exit 0
|
|
176
|
+
;;
|
|
177
|
+
-d|--dry-run)
|
|
178
|
+
DRY_RUN=true
|
|
179
|
+
shift
|
|
180
|
+
;;
|
|
181
|
+
-n|--namespace)
|
|
182
|
+
SPECIFIC_NAMESPACE="$2"
|
|
183
|
+
shift 2
|
|
184
|
+
;;
|
|
185
|
+
*)
|
|
186
|
+
echo "Unknown option: $1"
|
|
187
|
+
show_usage
|
|
188
|
+
exit 1
|
|
189
|
+
;;
|
|
190
|
+
esac
|
|
191
|
+
done
|
|
192
|
+
|
|
193
|
+
# Main execution
|
|
194
|
+
if [ "$DRY_RUN" = true ]; then
|
|
195
|
+
echo "DRY RUN MODE - Commands that would be executed:"
|
|
196
|
+
# Override run_snapquery for dry run
|
|
197
|
+
run_snapquery() {
|
|
198
|
+
local domain="$1"
|
|
199
|
+
local namespace="$2"
|
|
200
|
+
local endpoint="$3"
|
|
201
|
+
echo "Would run: snapquery -d -tq -en '$endpoint' --context 'cmd_line_tests' --domain '$domain' --namespace '$namespace'"
|
|
202
|
+
}
|
|
203
|
+
fi
|
|
204
|
+
|
|
205
|
+
if [ -n "$SPECIFIC_NAMESPACE" ]; then
|
|
206
|
+
# Process specific namespace
|
|
207
|
+
local namespace="${SPECIFIC_NAMESPACE%%@*}"
|
|
208
|
+
local domain="${SPECIFIC_NAMESPACE#*@}"
|
|
209
|
+
echo "Processing specific namespace: $domain/$namespace"
|
|
210
|
+
execute_queries_safe "$domain" "$namespace"
|
|
211
|
+
else
|
|
212
|
+
# Process all namespaces
|
|
213
|
+
process_namespace_data
|
|
214
|
+
fi
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.3"
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Created on 2025-12-04
|
|
3
|
+
|
|
4
|
+
@author: wf
|
|
5
|
+
"""
|
|
6
|
+
from argparse import ArgumentParser, Namespace
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
from basemkit.base_cmd import BaseCmd
|
|
10
|
+
from snapquery.query_set_tool import QuerySetTool
|
|
11
|
+
from snapquery.version import Version
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class QuerySetCmdVersion(Version):
|
|
15
|
+
"""Version information"""
|
|
16
|
+
name = "query-set"
|
|
17
|
+
description = "QuerySet tool"
|
|
18
|
+
|
|
19
|
+
class QuerySetCmd(BaseCmd):
|
|
20
|
+
"""
|
|
21
|
+
Command Line Interface for Query Set handling
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def add_arguments(self, parser: ArgumentParser):
|
|
25
|
+
"""
|
|
26
|
+
Add command-specific arguments.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
parser: ArgumentParser to add arguments to
|
|
30
|
+
"""
|
|
31
|
+
super().add_arguments(parser)
|
|
32
|
+
# Conversion options
|
|
33
|
+
parser.add_argument(
|
|
34
|
+
"--convert",
|
|
35
|
+
action="store_true",
|
|
36
|
+
help="Convert a NamedQuerySet",
|
|
37
|
+
)
|
|
38
|
+
parser.add_argument(
|
|
39
|
+
"-i",
|
|
40
|
+
"--input",
|
|
41
|
+
dest="input",
|
|
42
|
+
help="Input file path or URL for a NamedQuerySet (JSON or YAML).",
|
|
43
|
+
)
|
|
44
|
+
parser.add_argument(
|
|
45
|
+
"-o",
|
|
46
|
+
"--output",
|
|
47
|
+
dest="output",
|
|
48
|
+
help="Output file path. If omitted, prints to stdout.",
|
|
49
|
+
)
|
|
50
|
+
parser.add_argument(
|
|
51
|
+
"--in-format",
|
|
52
|
+
choices=["auto", "json", "yaml"],
|
|
53
|
+
default="auto",
|
|
54
|
+
help="Input format. If 'auto', inferred from extension or tried JSON then YAML.",
|
|
55
|
+
)
|
|
56
|
+
parser.add_argument(
|
|
57
|
+
"--out-format",
|
|
58
|
+
choices=["yaml", "json"],
|
|
59
|
+
default="yaml",
|
|
60
|
+
help="Output format to write.",
|
|
61
|
+
)
|
|
62
|
+
parser.add_argument(
|
|
63
|
+
"--indent",
|
|
64
|
+
type=int,
|
|
65
|
+
default=2,
|
|
66
|
+
help="JSON pretty-print indentation for --out-format json.",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
# Short URL path: create a NamedQuerySet from one or more w.wiki URLs
|
|
70
|
+
parser.add_argument(
|
|
71
|
+
"--shorturl",
|
|
72
|
+
nargs="+",
|
|
73
|
+
help="One or more Wikidata short URLs (e.g., https://w.wiki/XXXX) to build a NamedQuerySet.",
|
|
74
|
+
)
|
|
75
|
+
parser.add_argument(
|
|
76
|
+
"--domain",
|
|
77
|
+
help="Domain for NamedQuery(s) (required with --shorturl).",
|
|
78
|
+
)
|
|
79
|
+
parser.add_argument(
|
|
80
|
+
"--namespace",
|
|
81
|
+
help="Namespace for NamedQuery(s) (required with --shorturl).",
|
|
82
|
+
)
|
|
83
|
+
parser.add_argument(
|
|
84
|
+
"--llm",
|
|
85
|
+
action="store_true",
|
|
86
|
+
help="Enable LLM enrichment (placeholder; not used in this snippet).",
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
def handle_args(self, args: Namespace) -> bool:
|
|
90
|
+
"""
|
|
91
|
+
Handle parsed arguments and execute scraping.
|
|
92
|
+
|
|
93
|
+
Args:
|
|
94
|
+
args: Parsed command-line arguments
|
|
95
|
+
|
|
96
|
+
Returns:
|
|
97
|
+
True if handled (no further processing needed)
|
|
98
|
+
"""
|
|
99
|
+
handled = super().handle_args(args)
|
|
100
|
+
if handled:
|
|
101
|
+
return True
|
|
102
|
+
|
|
103
|
+
if args.convert:
|
|
104
|
+
self._handle_convert(args)
|
|
105
|
+
return True
|
|
106
|
+
|
|
107
|
+
# Short URL → NamedQuerySet
|
|
108
|
+
if args.shorturl:
|
|
109
|
+
self._handle_shorturl(args)
|
|
110
|
+
return True
|
|
111
|
+
|
|
112
|
+
return False
|
|
113
|
+
|
|
114
|
+
def _handle_convert(self, args: Namespace) -> None:
|
|
115
|
+
"""
|
|
116
|
+
Handle the conversion workflow delegating to QuerySetTool.
|
|
117
|
+
"""
|
|
118
|
+
if not args.input:
|
|
119
|
+
raise ValueError("Missing --input for --convert")
|
|
120
|
+
|
|
121
|
+
tool = QuerySetTool()
|
|
122
|
+
nq_set = tool.load_query_set(input_src=args.input, input_format=args.in_format)
|
|
123
|
+
|
|
124
|
+
self._output_dataset(nq_set, args)
|
|
125
|
+
|
|
126
|
+
def _handle_shorturl(self, args: Namespace) -> None:
|
|
127
|
+
"""
|
|
128
|
+
Handle the short URL workflow delegating to QuerySetTool.
|
|
129
|
+
"""
|
|
130
|
+
if not args.domain or not args.namespace:
|
|
131
|
+
raise ValueError("--domain and --namespace are required with --shorturl")
|
|
132
|
+
|
|
133
|
+
tool = QuerySetTool()
|
|
134
|
+
nq_set = tool.get_query_set_from_short_urls(
|
|
135
|
+
short_urls=args.shorturl,
|
|
136
|
+
domain=args.domain,
|
|
137
|
+
namespace=args.namespace
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
self._output_dataset(nq_set, args)
|
|
141
|
+
|
|
142
|
+
def _output_dataset(self, nq_set, args: Namespace) -> None:
|
|
143
|
+
"""
|
|
144
|
+
Helper to output a NamedQuerySet to file or stdout.
|
|
145
|
+
"""
|
|
146
|
+
out_fmt = args.out_format
|
|
147
|
+
if args.output:
|
|
148
|
+
# Save to file
|
|
149
|
+
if out_fmt == "yaml":
|
|
150
|
+
nq_set.save_to_yaml_file(args.output)
|
|
151
|
+
else:
|
|
152
|
+
nq_set.save_to_json_file(args.output, indent=args.indent)
|
|
153
|
+
else:
|
|
154
|
+
# Print to stdout
|
|
155
|
+
if out_fmt == "yaml":
|
|
156
|
+
sys.stdout.write(nq_set.to_yaml(sort_keys=False))
|
|
157
|
+
else:
|
|
158
|
+
sys.stdout.write(nq_set.to_json(indent=args.indent))
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def main(argv=None):
|
|
162
|
+
"""Main entry point."""
|
|
163
|
+
exit_code = QuerySetCmd.main(QuerySetCmdVersion(), argv)
|
|
164
|
+
return exit_code
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
if __name__ == "__main__":
|
|
168
|
+
main()
|