[tracker/wip/sam/resource: 18/18] tracker-extract: Allow Turtle serialization
- From: Sam Thursfield <sthursfield src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/sam/resource: 18/18] tracker-extract: Allow Turtle serialization
- Date: Sun, 10 Apr 2016 21:43:37 +0000 (UTC)
commit 829addd229fb839b50c5963d85cdc8c48cb8f657
Author: Sam Thursfield <sam afuera me uk>
Date: Sat Apr 9 17:12:27 2016 +0100
tracker-extract: Allow Turtle serialization
src/libtracker-common/tracker-enums.h | 1 +
src/tracker-extract/tracker-extract.c | 20 ++++++++++++++++++++
src/tracker-extract/tracker-main.c | 2 +-
3 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/src/libtracker-common/tracker-enums.h b/src/libtracker-common/tracker-enums.h
index edce490..5121a72 100644
--- a/src/libtracker-common/tracker-enums.h
+++ b/src/libtracker-common/tracker-enums.h
@@ -43,6 +43,7 @@ typedef enum {
TRACKER_SERIALIZATION_FORMAT_JSON,
TRACKER_SERIALIZATION_FORMAT_JSON_LD,
TRACKER_SERIALIZATION_FORMAT_SPARQL,
+ TRACKER_SERIALIZATION_FORMAT_TURTLE,
} TrackerSerializationFormat;
G_END_DECLS
diff --git a/src/tracker-extract/tracker-extract.c b/src/tracker-extract/tracker-extract.c
index bb7a525..a253b83 100644
--- a/src/tracker-extract/tracker-extract.c
+++ b/src/tracker-extract/tracker-extract.c
@@ -824,6 +824,26 @@ tracker_extract_get_metadata_by_cmdline (TrackerExtract *object,
text = tracker_sparql_builder_get_result (builder);
g_print ("%s\n", text);
+ } else if (output_format == TRACKER_SERIALIZATION_FORMAT_TURTLE) {
+ for (GList *l = resources; l; l = l->next) {
+ char *turtle;
+
+ /* If this was going into the tracker-store we'd generate a unique ID
+ * here, so that the data persisted across file renames.
+ */
+ tracker_resource_set_identifier (TRACKER_RESOURCE (l->data), uri);
+
+ turtle = tracker_resource_print_turtle (TRACKER_RESOURCE (l->data),
+
tracker_namespace_manager_get_default ());
+
+ if (turtle) {
+ g_print ("%s\n", turtle);
+ g_free (turtle);
+ } else {
+ g_printerr ("%s\n", error->message);
+ g_error_free (error);
+ }
+ }
} else {
/* FIXME: we should return a JSON-LD @graph if there are multiple resources,
* not a sequence of JSON documents!!!
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index 0baf9cd..4e70b72 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -96,7 +96,7 @@ static GOptionEntry entries[] = {
N_("Force a module to be used for extraction (e.g. \"foo\" for \"foo.so\")"),
N_("MODULE") },
{ "output-format", 'o', 0, G_OPTION_ARG_STRING, &output_format_name,
- N_("Output results format: 'json' or 'sparql'"),
+ N_("Output results format: 'json', 'sparql', or 'turtle'"),
N_("FORMAT") },
{ "version", 'V', 0,
G_OPTION_ARG_NONE, &version,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]