def load(self, source): # TODO: don't let duplicate trust levels on certain subjects be entered! print "Update Listener: parsing input" # this is the main object we're concerned with store = TripleStore() store.load(source) # For each foaf:Person in the store print out its mbox property. truster = store.subjects(self.TRUST["trusts"]).next() f = store.objects(truster, self.WOT["fingerprint"]).next() p = self.server.getPerson(f) for trustee in store.objects(truster, self.TRUST["trusts"]): f2 = store.objects(trustee, self.WOT["fingerprint"]).next() # we do this to make sure they exist. p2 = self.server.getPerson(f2) for value, resource in store.predicate_objects(trustee): if value in self.trustValues: p.addTrustLink(f2, resource.split("#")[1], resource, TrustValue.TrustValue(value.split("#")[1]))
def load(self, source): print "Update Listener: parsing input: %s" % source # this is the main object we're concerned with store = TripleStore() store.load(source) # For each foaf:Person in the store print out its mbox property. truster = store.subjects(self.TRUST["trusts"]).next() f = store.objects(truster, self.WOT["fingerprint"]).next() p = self.server.getPerson(f) for trustee in store.objects(truster, self.TRUST["trusts"]): f2 = store.objects(trustee, self.WOT["fingerprint"]).next() # we do this to make sure they exist. p2 = self.server.getPerson(f2) for value, resource in store.predicate_objects(trustee): if value in self.trustValues: self.server.lock.acquire_write() #time.sleep(15) p.addTrustLink(f2, resource.split("#")[1], resource, BasicTrustValue(value.split("#")[1])) self.server.lock.release_write()
trust = TripleStore() trust.load("http://www.abundantplunder.com/trust/owl/trust.owl#") trustValues = [] for s in trust.subjects(RDF["subPropertyOf"], TRUST["trustValue"]): trustValues.append(s) # For each foaf:Person in the store print out its mbox property. print "--- printing trust: ---" truster = store.subjects(TRUST["trusts"]).next() f = store.objects(truster, WOT["fingerprint"]).next() p = Person.Person(f) people[f] = p for trustee in store.objects(truster, TRUST["trusts"]): f2 = store.objects(trustee, WOT["fingerprint"]).next() p2 = Person.Person(f2) people[f2] = p2 for value, subject in store.predicate_objects(trustee): if value in trustValues: name = subject.split("#")[1] resource = subject value = value.split("#")[1] tc = TrustConnection.TrustConnection() tc.setFingerprint(f2) tv = TrustValue.TrustValue(value) ts = TrustSubject.TrustSubject(name, resource, tv) tc.addTrustSubject(ts) p.addConnection(tc) for p in people: print people[p]