From 3f6d996119722ca95d56ae07e3949dbbe454aaf0 Mon Sep 17 00:00:00 2001 From: Benjamin Drung Date: Thu, 10 Jun 2010 13:48:58 +0200 Subject: * Switch from python-rdflib to python-librdf; thanks to Willi Mann for the patch. - update src/dh_xul-ext - update src/install-xpi --- src/install-xpi | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'src/install-xpi') diff --git a/src/install-xpi b/src/install-xpi index 61771e9..3d657ad 100755 --- a/src/install-xpi +++ b/src/install-xpi @@ -28,31 +28,32 @@ import subprocess import sys import zipfile -from rdflib import Namespace -from rdflib.Graph import Graph +import RDF # error codes COMMAND_LINE_SYNTAX_ERROR = 1 XPI_FILE_DOES_NOT_EXISTS = 2 +def get_query_field_id_as_list(rdf_path, query_string): + ret = [] + model = RDF.Model() + parser = RDF.Parser(name="rdfxml") + stream = parser.parse_into_model(model, "file:" + rdf_path) + query = RDF.Query("PREFIX em: " + query_string, query_language="sparql") + results = query.execute(model) + for result in results: + ret.append(str(result["id"])) + return ret + + def get_target_applications(script_name, install_rdf, verbose=False): - target_applications = [] - rdf_graph = Graph() - rdf_graph.parse(install_rdf) - query = "SELECT ?id WHERE { ?x1 em:targetApplication ?x2 . ?x2 em:id ?id }" - results = rdf_graph.query(query, initNs=dict(em=Namespace("http://www.mozilla.org/2004/em-rdf#"))) - for target in results: - target_applications.append(str(target[0])) + target_applications = get_query_field_id_as_list(install_rdf, + "SELECT ?id WHERE { ?x1 em:targetApplication ?x2 . ?x2 em:id ?id }") return target_applications def get_extension_id(install_rdf): - extension_ids = set() - rdf_graph = Graph() - rdf_graph.parse(install_rdf) - query = "SELECT ?id WHERE {?x1 em:targetApplication ?x2 . ?x1 em:id ?id }" - results = rdf_graph.query(query, initNs=dict(em=Namespace("http://www.mozilla.org/2004/em-rdf#"))) - for result in results: - extension_ids.add(str(result[0])) + extension_ids = set(get_query_field_id_as_list(install_rdf, + "SELECT ?id WHERE {?x1 em:targetApplication ?x2 . ?x1 em:id ?id }")) return extension_ids.pop() def get_arch(package): -- cgit v1.2.3