def export_csv():
	store = Store(reader='rdflib', writer='rdflib', rdflib_store='IOMemory')
	session = Session(store)
	print 'Load HEP data'
	store.load_triples(source='HEPont.rdf')
	Concept = session.get_class(namespace.SKOS['Concept'])
	all_concepts = Concept.all()
	print 'Found %d concepts' % (len(all_concepts))
	for concept in all_concepts:
		try:
			concept_uri = concept.subject
			concept_prefLabel = concept.skos_prefLabel.first
			print '%s;%s' % (concept_uri, concept_prefLabel)
		except:
			pass
Exemple #2
0
    def test_multiples(self):
        """ Test synchronization between empty attribute and rdf_direct. """

        store = Store()
        session = Session(store)
        
        Person = session.get_class(surf.ns.FOAF.Person)
        
        rob = session.get_resource("http://Robert", Person)
        rob.foaf_name = "Robert"
        michael = session.get_resource("http://Michael", Person)
        michael.foaf_name = "Michael"
        
        # Should not fail.
        store.save(rob, michael)
        store.update(rob, michael)
        store.remove(rob, michael)
Exemple #3
0
    def test_multiples(self):
        """ Test synchronization between empty attribute and rdf_direct. """

        store = Store(log_level=logging.NOTSET)
        session = Session(store)

        Person = session.get_class(surf.ns.FOAF.Person)

        rob = session.get_resource("http://Robert", Person)
        rob.foaf_name = "Robert"
        michael = session.get_resource("http://Michael", Person)
        michael.foaf_name = "Michael"

        # Should not fail.
        store.save(rob, michael)
        store.update(rob, michael)
        store.remove(rob, michael)
Exemple #4
0
def test_multiples():
    """
    Test synchronization between empty attribute and rdf_direct.
    """

    store = Store(log_level=logging.NOTSET)
    session = Session(store)

    Person = session.get_class(surf.ns.FOAF.Person)

    rob = session.get_resource("http://Robert", Person)
    rob.foaf_name = "Robert"
    michael = session.get_resource("http://Michael", Person)
    michael.foaf_name = "Michael"

    try:
        store.save(rob, michael)
        store.update(rob, michael)
        store.remove(rob, michael)
    except Exception, e:
        pytest.fail(e.message, pytrace=True)
Exemple #5
0
#!/usr/bin/env python

__author__ = 'Adam R. Smith'
__license__ = 'Apache 2.0'

from surf import Store, Session, ns

store = Store(reader='rdflib', writer='rdflib', rdflib_store='IOMemory')

session = Session(store)

print 'Load RDF data'
store.load_triples(source='http://www.w3.org/People/Berners-Lee/card.rdf')

Person = session.get_class(ns.FOAF['Person'])

all_persons = Person.all()

print 'Found %d persons that Tim Berners-Lee knows' % (len(all_persons))
for person in all_persons:
    print person.foaf_name.first

#create a person object
somebody = Person()
somebody_else = Person()

somebody.foaf_knows = somebody_else
Exemple #6
0
#!/usr/bin/env python

__author__ = 'Adam R. Smith'

from surf import Store, Session, ns

store = Store(reader='rdflib', writer='rdflib', rdflib_store = 'IOMemory')

session = Session(store)

print 'Load RDF data'
store.load_triples(source='http://www.w3.org/People/Berners-Lee/card.rdf')

Person = session.get_class(ns.FOAF['Person'])

all_persons = Person.all()

print 'Found %d persons that Tim Berners-Lee knows'%(len(all_persons))
for person in all_persons:
    print person.foaf_name.first

#create a person object
somebody = Person()
somebody_else = Person()

somebody.foaf_knows = somebody_else