Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/semanticxo/metadatastore.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/semanticxo/metadatastore.py')
-rw-r--r--src/semanticxo/metadatastore.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/semanticxo/metadatastore.py b/src/semanticxo/metadatastore.py
index f6f9081..66e5893 100644
--- a/src/semanticxo/metadatastore.py
+++ b/src/semanticxo/metadatastore.py
@@ -3,6 +3,7 @@ Created on Apr 11, 2011
@author: cgueret
'''
+import logging
import httplib
import urllib
import time
@@ -11,6 +12,8 @@ from rdflib import ConjunctiveGraph, RDF, URIRef, Namespace, Literal
OLPC = Namespace("http://example.org/")
OLPC_TERMS = Namespace("http://example.org/terms#")
+_QUERY_INT_KEY = ['timestamp', 'filesize', 'creation_time']
+
class MetadataStore(object):
'''
Store metadata into the triple store using HTTP calls.
@@ -59,16 +62,22 @@ class MetadataStore(object):
def retrieve(self, uid, properties=None):
- print '[MDS] retrieve ' + uid
+ logging.debug('[MDS] retrieve %r' % uid)
props = {}
query = 'SELECT * WHERE { <%s> ?p ?o}' % self._get_resource(uid)
for line in self._sparql_get(query):
- print line
-
+ (id, prop, value) = line.split(',')
+ if prop[4:-1].startswith(OLPC_TERMS):
+ key=prop[4:-1].split(OLPC_TERMS)[1]
+ if key in _QUERY_INT_KEY:
+ props[key] = int(value[1:-1])
+ else:
+ props[key] = value[1:-1]
+
# HACK: This is expected to be always present
if 'creation_time' not in props:
props['creation_time'] = int(time.time())
-
+
return props
def delete(self, uid):