Code Monkey home page Code Monkey logo

Comments (2)

amercader avatar amercader commented on June 23, 2024

Mapping the formats provided in the remote DCAT document to the ones that CKAN previews understand is out of the scope of this extension for now, and is up to extensions to define them. I've created #18 to add this feature.

In this particular case the remote file is defining them "properly" as mime types, which is what CKAN core should eventually support (see ckan/ckan#1350 and ckan/ckan#1336).

In the meantime, is up to particular extensions to implement the mapping. You can do this by extending the DCATXMLHarvester class and implementing a modify_package_dict method on your own extension. Something like this should get you started:

# ckanext.myext.harvesters.py

from ckanext.dcat.harvesters import DCATXMLHarvester

class MyDCATHarvester(DCATXMLHarvester):

    def modify_package_dict(self, package_dict, dcat_dict, harvest_object):
        # See https://github.com/ckan/ckan/blob/master/ckan/config/resource_formats.json
        mapping = {
             'application/xml': 'xml',
             'application/gzip': 'gz',
             # ...

        }

        for resource in package_dict.get('resources', []):
            if resource.get('format') in mapping:
                resource['format'] = mapping[resource['format']]

        return package_dict

To register your own DCAT harvester, add it as normal plugin to the setup.py file of your extension:

   entry_points=\
    """ 
    [ckan.plugins]
    # Add plugins here, eg
    my_dcat_harvester=ckanext.myext.harvesters:MyDCATHarvester
    """,

And then add it to your ini file:

ckan.plugins = ... my_dcat_harvester

Hope this helps

from ckanext-dcat.

amercader avatar amercader commented on June 23, 2024

The RDF harvester (dcat_rdf_harvester) handles this, setting up resource['format'] and resource['mimetype'] properly from the DCAT fields. Please use this harvester instead of the XML based one (https://github.com/ckan/ckanext-dcat#xml-dcat-harvester-deprecated)

from ckanext-dcat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.