You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This patch is code-motion to give function names to chunks of
`case_sparql_select:main`.
Some upcoming patch series are going to add features that, when taken
together, introduce non-trivial parameter-value cross-dependencies.
Moving functionality to functions enables combinatoric testing in a
`pytest` space, rather than resorting to copying, pasting, and tweaking
many Makefile lines. A future patch series will add the `pytest`
script.
Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
help="Ontology version to use to supplement query, such as for subclass querying. Does not require networking to use. Default is most recent CASE release. Passing 'none' will mean no pre-built CASE ontology versions accompanying this tool will be included in the analysis.",
68
-
)
69
-
parser.add_argument(
70
-
"--disallow-empty-results",
71
-
action="store_true",
72
-
help="Raise error if no results are returned for query.",
73
-
)
74
-
parser.add_argument(
75
-
"--use-prefixes",
76
-
action="store_true",
77
-
help="Abbreviate node IDs according to graph's encoded prefixes. (This will use prefixes in the graph, not the query.)",
78
-
)
79
-
parser.add_argument(
80
-
"out_table",
81
-
help="Expected extensions are .html for HTML tables, .md for Markdown tables, .csv for comma-separated values, and .tsv for tab-separated values.",
82
-
)
83
-
parser.add_argument(
84
-
"in_sparql",
85
-
help="File containing a SPARQL SELECT query. Note that prefixes not mapped with a PREFIX statement will be mapped according to their first occurrence among input graphs.",
86
-
)
87
-
parser.add_argument("in_graph", nargs="+")
88
-
args=parser.parse_args()
89
-
90
-
graph=rdflib.Graph()
91
-
forin_graph_filenameinargs.in_graph:
92
-
graph.parse(in_graph_filename)
93
-
94
-
# Inherit prefixes defined in input context dictionary.
help="Ontology version to use to supplement query, such as for subclass querying. Does not require networking to use. Default is most recent CASE release. Passing 'none' will mean no pre-built CASE ontology versions accompanying this tool will be included in the analysis.",
176
+
)
177
+
parser.add_argument(
178
+
"--disallow-empty-results",
179
+
action="store_true",
180
+
help="Raise error if no results are returned for query.",
181
+
)
182
+
parser.add_argument(
183
+
"--use-prefixes",
184
+
action="store_true",
185
+
help="Abbreviate node IDs according to graph's encoded prefixes. (This will use prefixes in the graph, not the query.)",
186
+
)
187
+
parser.add_argument(
188
+
"out_table",
189
+
help="Expected extensions are .html for HTML tables, .md for Markdown tables, .csv for comma-separated values, and .tsv for tab-separated values.",
190
+
)
191
+
parser.add_argument(
192
+
"in_sparql",
193
+
help="File containing a SPARQL SELECT query. Note that prefixes not mapped with a PREFIX statement will be mapped according to their first occurrence among input graphs.",
194
+
)
195
+
196
+
parser.add_argument("in_graph", nargs="+")
197
+
args=parser.parse_args()
176
198
199
+
output_mode: str
200
+
ifargs.out_table.endswith(".csv"):
201
+
output_mode="csv"
202
+
elifargs.out_table.endswith(".html"):
203
+
output_mode="html"
204
+
elifargs.out_table.endswith(".json"):
205
+
output_mode="json"
206
+
elifargs.out_table.endswith(".md"):
207
+
output_mode="md"
208
+
elifargs.out_table.endswith(".tsv"):
209
+
output_mode="tsv"
210
+
else:
211
+
raiseNotImplementedError("Output file extension not implemented.")
0 commit comments