summaryrefslogtreecommitdiff
path: root/src/install-xpi
diff options
context:
space:
mode:
authorBenjamin Drung <bdrung@ubuntu.com>2010-06-10 13:48:58 +0200
committerBenjamin Drung <bdrung@ubuntu.com>2010-06-10 13:48:58 +0200
commit3f6d996119722ca95d56ae07e3949dbbe454aaf0 (patch)
tree80deecb6ffb71ce7d38c4ccd8c19e6e018fb1d52 /src/install-xpi
parent29562cae5befe08b560848f328a2070411817e1b (diff)
* Switch from python-rdflib to python-librdf; thanks to Willi Mann for the
patch. - update src/dh_xul-ext - update src/install-xpi
Diffstat (limited to 'src/install-xpi')
-rwxr-xr-xsrc/install-xpi33
1 files changed, 17 insertions, 16 deletions
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: <http://www.mozilla.org/2004/em-rdf#> " + 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):