File commands¶
kurra.cli.commands.file ¶
CLI commands for working with RDF files.
reformat_command ¶
reformat_command(file_or_dir: str = typer.Argument(..., help='The file or directory of RDF files to be formatted'), check: bool = typer.Option(False, '--check', '-c', help='Check whether files will be formatted without applying the effect.'), output_format: str = typer.Option('longturtle', '--output-format', '-f', help=f'Indicate the output RDF format. Available are {list(RDF_FILE_SUFFIXES.keys())}.'), output_filename: str = typer.Option(None, '--output-filename', '-o', help='the name of the file you want to write the reformatted content to')) -> None
Reformat one RDF file or every RDF file in a directory to a given format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_or_dir
|
str
|
The file or directory of RDF files to be formatted. |
Argument(..., help='The file or directory of RDF files to be formatted')
|
check
|
bool
|
If True, check whether files will be changed by this command without applying the effect. |
Option(False, '--check', '-c', help='Check whether files will be formatted without applying the effect.')
|
output_format
|
str
|
The RDF serialization to write. See |
Option('longturtle', '--output-format', '-f', help=f'Indicate the output RDF format. Available are {list(keys())}.')
|
output_filename
|
str
|
The name of the file to write the reformatted content to. |
Option(None, '--output-filename', '-o', help='the name of the file you want to write the reformatted content to')
|
Raises:
| Type | Description |
|---|---|
SystemExit
|
With status 1, if |
Source code in kurra/cli/commands/file.py
merge_command ¶
merge_command(files: list[Path], destination: Path | None = None, output_format: str = 'longturtle') -> None
Merge multiple RDF files into a single graph or dataset document.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
files
|
list[Path]
|
The RDF files to merge. |
required |
destination
|
Path | None
|
The output file path. If omitted, the merged RDF is printed. |
None
|
output_format
|
str
|
The RDFLib serialization format for the merged RDF. See |
'longturtle'
|
Source code in kurra/cli/commands/file.py
hierarchy_command ¶
Print the class, property, or concept hierarchy found in an RDF source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_or_url
|
str
|
An RDF file path or HTTP URL. |
required |
graph_iri
|
str | None
|
The named graph to use, for remote, TriG, or JSON-LD sources. |
None
|
use_names
|
bool
|
If True, display resource names instead of IRIs where available. |
False
|
Source code in kurra/cli/commands/file.py
quads_command ¶
Export (prints or saves) triples from an RDF source as quads under a given graph identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_or_str
|
Path
|
The RDF file to read triples from. |
required |
graph_iri
|
str
|
The graph IRI to assign to every exported quad. |
required |
destination
|
Path
|
The path of the file to save the quads to. If omitted, the result is printed to the console. |
None
|
Source code in kurra/cli/commands/file.py
query_command ¶
query_command(path_or_url: Path, q: str, response_format: str = typer.Option('table', '--response-format', '-f', help="The response format of the SPARQL query. Either 'table' (default) or 'json'"), username: str = None, password: str = None, timeout: int = 60) -> None
Run a SPARQL query against a local RDF file or a remote SPARQL endpoint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_or_url
|
Path
|
A local RDF file path or a SPARQL endpoint URL to query. |
required |
q
|
str
|
A SPARQL query string, or the path to a file containing one. |
required |
response_format
|
str
|
The response format of the SPARQL query. Either |
Option('table', '--response-format', '-f', help="The response format of the SPARQL query. Either 'table' (default) or 'json'")
|
username
|
str
|
Fuseki username, if the endpoint requires authentication. |
None
|
password
|
str
|
Fuseki password, if the endpoint requires authentication. |
None
|
timeout
|
int
|
Timeout per request, in seconds. |
60
|