ckan/lib/cli.py
def export_datasets(self, out_folder):
        '''
        Export datasets as RDF to an output folder.
        '''
        from ckan.common import config
        import ckan.model as model
        import ckan.logic as logic
        import ckan.lib.helpers as h

        # Create output folder if not exists
        if not os.path.isdir(out_folder):
            os.makedirs(out_folder)

        fetch_url = config['ckan.site_url']
        user = logic.get_action('get_site_user')({'model': model, 'ignore_auth': True}, {})
        context = {'model': model, 'session': model.Session, 'user': user['name']}
        dataset_names = logic.get_action('package_list')(context, {})
        for dataset_name in dataset_names:
            dd = logic.get_action('package_show')(context, {'id': dataset_name})
            if not dd['state'] == 'active':
                continue

            url = h.url_for('dataset.read', id=dd['name'])

            url = urljoin(fetch_url, url[1:]) + '.rdf'
            try:
                fname = os.path.join(out_folder, dd['name']) + ".rdf"
                try:
                    r = urlopen(url).read()
                except HTTPError as e:
                    if e.code == 404:
                        error('Please install ckanext-dcat and enable the ' +
                              '`dcat` plugin to use the RDF serializations')
                with open(fname, 'wb') as f:
                    f.write(r)
            except IOError as ioe:
                sys.stderr.write(str(ioe) + "\n")

        Export datasets as RDF to an output folder.
        
Export datasets as RDF to an output folder.
Export datasets as RDF to an output folder .
def export_datasets(self, out_folder):
        from ckan.common import config
        import ckan.model as model
        import ckan.logic as logic
        import ckan.lib.helpers as h
        if not os.path.isdir(out_folder):
            os.makedirs(out_folder)
        fetch_url = config['ckan.site_url']
        user = logic.get_action('get_site_user')({'model': model, 'ignore_auth': True}, {})
        context = {'model': model, 'session': model.Session, 'user': user['name']}
        dataset_names = logic.get_action('package_list')(context, {})
        for dataset_name in dataset_names:
            dd = logic.get_action('package_show')(context, {'id': dataset_name})
            if not dd['state'] == 'active':
                continue
            url = h.url_for('dataset.read', id=dd['name'])
            url = urljoin(fetch_url, url[1:]) + '.rdf'
            try:
                fname = os.path.join(out_folder, dd['name']) + ".rdf"
                try:
                    r = urlopen(url).read()
                except HTTPError as e:
                    if e.code == 404:
                        error('Please install ckanext-dcat and enable the ' +
                              '`dcat` plugin to use the RDF serializations')
                with open(fname, 'wb') as f:
                    f.write(r)
            except IOError as ioe:
                sys.stderr.write(str(ioe) + "\n")
def export_datasets ( self , out_folder ) : from ckan . common import config import ckan . model as model import ckan . logic as logic import ckan . lib . helpers as h if not os . path . isdir ( out_folder ) : os . makedirs ( out_folder ) fetch_url = config [ 'ckan.site_url' ] user = logic . get_action ( 'get_site_user' ) ( { 'model' : model , 'ignore_auth' : True } , { } ) context = { 'model' : model , 'session' : model . Session , 'user' : user [ 'name' ] } dataset_names = logic . get_action ( 'package_list' ) ( context , { } ) for dataset_name in dataset_names : dd = logic . get_action ( 'package_show' ) ( context , { 'id' : dataset_name } ) if not dd [ 'state' ] == 'active' : continue url = h . url_for ( 'dataset.read' , id = dd [ 'name' ] ) url = urljoin ( fetch_url , url [ 1 : ] ) + '.rdf' try : fname = os . path . join ( out_folder , dd [ 'name' ] ) + ".rdf" try : r = urlopen ( url ) . read ( ) except HTTPError as e : if e . code == 404 : error ( 'Please install ckanext-dcat and enable the ' + '`dcat` plugin to use the RDF serializations' ) with open ( fname , 'wb' ) as f : f . write ( r ) except IOError as ioe : sys . stderr . write ( str ( ioe ) + "\n" )
Export datasets as RDF to an output folder.
Export datasets as RDF to an output folder .
'''
        Export datasets as RDF to an output folder.
        ''' # Create output folder if not exists
self
out_folder