summaryrefslogtreecommitdiff
path: root/src/tracker/tracker-extract.c
diff options
context:
space:
mode:
authorSam Thursfield <ssssam@gmail.com>2016-03-27 00:15:33 +0000
committerSam Thursfield <sam@afuera.me.uk>2016-07-14 13:20:48 +0100
commit8cc026da8cdebba4d5b17ed23841ec59d79f60e3 (patch)
treeeb5af6ba2150d6dcd86a70582ab736c9eb48b3ce /src/tracker/tracker-extract.c
parent032e2a7ed874bacce4ca5f0dd9ddbad6ab8f5f81 (diff)
downloadtracker-wip/sam/resource-rebase-6.tar.gz
Use TrackerResource instead of TrackerSparqlBuilder in all extractorswip/sam/resource-rebase-6
For a long time, all the Tracker extractors have manually constructed a SPARQL update command using TrackerSparqlBuilder to represent their output. This commit changes all of them to use the TrackerResource class instead, which makes the code a lot more concise and readable. This introduces some API breaks in the internal libtracker-extract library. This has been a private library since Tracker 0.16 or earlier, so it's fine. If the extractors only output SPARQL then they are only useful to people who are using a SPARQL store. Now we can output a serialization format like Turtle as well. This will hopefully make the extract modules useful outside of Tracker itself. I've tried to preserve the behaviour of the extractors as much as possible, but there are two things that are now handled differently: * nao:Tag resources are given a fixed URI based on the tag label, such as <urn:tag:My_Tag>. Previously they were inserted as blank nodes, so tracker-store would give them unique IDs like <urn:uuid:1234...> * All extractors created nco:Contact resources for content publishers, but previously some would assign fixed URIs based on the name <urn:contact:James%20Joyce>, while others would insert them as blank nodes so they would be assigned unique IDs like <urn:uuid:1234...>. Now, all extractors create nco:Contact resources with fixed URIs based on the content creator's name. https://bugzilla.gnome.org/show_bug.cgi?id=767472
Diffstat (limited to 'src/tracker/tracker-extract.c')
-rw-r--r--src/tracker/tracker-extract.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/tracker/tracker-extract.c b/src/tracker/tracker-extract.c
index d4979f3fc..fad25f492 100644
--- a/src/tracker/tracker-extract.c
+++ b/src/tracker/tracker-extract.c
@@ -31,6 +31,7 @@
#include "tracker-extract.h"
static gchar *verbosity;
+static gchar *output_format = "turtle";
static gchar **filenames;
#define EXTRACT_OPTIONS_ENABLED() \
@@ -40,6 +41,9 @@ static GOptionEntry entries[] = {
{ "verbosity", 'v', 0, G_OPTION_ARG_STRING, &verbosity,
N_("Sets the logging verbosity to LEVEL ('debug', 'detailed', 'minimal', 'errors') for all processes"),
N_("LEVEL") },
+ { "output-format", 'o', 0, G_OPTION_ARG_STRING, &output_format,
+ N_("Output results format: 'sparql', or 'turtle'"),
+ N_("FORMAT") },
{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames,
N_("FILE"),
N_("FILE") },
@@ -48,7 +52,8 @@ static GOptionEntry entries[] = {
static gint
-extract_files (TrackerVerbosity verbosity)
+extract_files (TrackerVerbosity verbosity,
+ char *output_format)
{
char **p;
char *tracker_extract_path;
@@ -60,7 +65,10 @@ extract_files (TrackerVerbosity verbosity)
tracker_extract_path = g_build_filename(LIBEXECDIR, "tracker-extract", NULL);
for (p = filenames; *p; p++) {
- char *argv[] = {tracker_extract_path, "--verbosity", verbosity_str, "--file", *p, NULL};
+ char *argv[] = {tracker_extract_path,
+ "--output-format", output_format,
+ "--verbosity", verbosity_str,
+ "--file", *p, NULL };
g_spawn_sync(NULL, argv, NULL, G_SPAWN_DEFAULT, NULL, NULL, NULL, NULL, NULL, &error);
@@ -99,7 +107,7 @@ extract_run (void)
}
}
- return extract_files (verbosity_level);
+ return extract_files (verbosity_level, output_format);
}
static int