[ckan-dev] dcat_to_ckan
Friedrich Lindenberg
friedrich.lindenberg at okfn.org
Wed May 25 18:35:05 UTC 2011
Hi Adria,
the mapper is using a subclass of Graph (also called Graph, kill me)
that you will get by importing from dcat.core. As a very simple
example, see https://bitbucket.org/okfn/dcat-tools/src/0ec5012bf12a/dcat/tests/mapper.py
for basic usage.
The second parameter is the dataset URI, so the typical usage for the
script would be to run in a look over all dcat:Datasets in the given
graph.
- Friedrich
2011/5/25 Adrià Mercader <amercadero at gmail.com>:
> Hi Friedrich,
> Two questions regardind the dcat_to_ckan mapper:
> * What is the second parameter (dataset) supposed to be?
> * I got an exception when I try to execute it (full traceback at the end):
> AttributeError: 'Graph' object has no attribute 'bound_query'
>
> Here is the code I'm using
>
> from ckanext.pdeu.dcat.core.mapper import dcat_to_ckan
> from rdflib.graph import Graph
> try: from cStringIO import StringIO
> except ImportError: from StringIO import StringIO
>
> # harvest_object.content is the content from
> http://www.opengov.se/data/1/rdf/, stored in the database
> graph = Graph()
> graph.parse(StringIO(harvest_object.content)
> dcat_to_ckan(graph,'http://test/')
>
> Any clues of what might be happening?
>
> Thanks,
> Adrià
>
>
>
> Traceback (most recent call last):
> File "/home/adria/dev/envs/ckan/bin/paster", line 8, in <module>
> load_entry_point('PasteScript==1.7.3', 'console_scripts', 'paster')()
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/paste/script/command.py",
> line 84, in run
> invoke(command, command_name, options, args[1:])
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/paste/script/command.py",
> line 123, in invoke
> exit_code = runner.run(args)
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/paste/script/command.py",
> line 218, in run
> result = self.command()
> File "/home/adria/dev/envs/ckan/src/ckanext-harvest/ckanext/harvest/commands/harvester.py",
> line 89, in command
> consumer.wait()
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/carrot/messaging.py",
> line 446, in wait
> it.next()
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/carrot/backends/pyamqplib.py",
> line 300, in consume
> self.channel.wait()
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/amqplib/client_0_8/abstract_channel.py",
> line 107, in wait
> return amqp_method(self, args, content)
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/amqplib/client_0_8/channel.py",
> line 1973, in _basic_deliver
> func(msg)
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/carrot/messaging.py",
> line 291, in _receive_callback
> self.receive(message.payload, message)
> File "/home/adria/dev/envs/ckan/lib/python2.6/site-packages/carrot/messaging.py",
> line 344, in receive
> callback(message_data, message)
> File "/home/adria/dev/envs/ckan/src/ckanext-harvest/ckanext/harvest/queue.py",
> line 136, in fetch_callback
> harvester.import_stage(obj)
> File "/home/adria/dev/envs/ckan/src/ckanext-pdeu/ckanext/pdeu/harvesters.py",
> line 371, in import_stage
> dcat_to_ckan(graph,'http://test/234234')
> File "/home/adria/dev/envs/ckan/src/ckanext-pdeu/ckanext/pdeu/dcat/core/mapper.py",
> line 52, in dcat_to_ckan
> data['name'] = first(_query("?dataset dc:identifier ?out"))
> File "/home/adria/dev/envs/ckan/src/ckanext-pdeu/ckanext/pdeu/dcat/core/mapper.py",
> line 27, in first
> for x in _q:
> File "/home/adria/dev/envs/ckan/src/ckanext-pdeu/ckanext/pdeu/dcat/core/mapper.py",
> line 17, in _query
> for row in graph.bound_query("SELECT DISTINCT ?out WHERE {%s}" % fragment,
> AttributeError: 'Graph' object has no attribute 'bound_query'
>
More information about the ckan-dev
mailing list