Esempio n. 1
0
def _export_resources_xml(zip_file, pkg_dict, request, response):
    file_names = {}
    for resource in pkg_dict['resources']:
        resource_name = h.resource_display_name(resource)
        if file_names.get(resource_name):
            resource_name = u'%s_%s' % (resource_name, resource['id'])
        else:
            file_names[resource_name] = True
        file_name = u'%s.xml' % resource_name
        output = export_resource_to_xml(resource)
        zip_file.writestr(file_name.encode('utf-8'), output.encode('utf-8'))
Esempio n. 2
0
def resource_display_name(*args, **kwargs):
    '''Return a display name for the given resource.

    This overrides CKAN's default resource_display_name template helper
    function and replaces 'Unnamed resource' with 'Unnamed file'.

    '''
    display_name = helpers.resource_display_name(*args, **kwargs)
    if display_name == 'Unnamed resource':
        display_name = 'Unnamed file'
    return display_name
Esempio n. 3
0
def resource_display_name(*args, **kwargs):
    '''Return a display name for the given resource.

    This overrides CKAN's default resource_display_name template helper
    function and replaces 'Unnamed resource' with 'Unnamed file'.

    '''
    display_name = helpers.resource_display_name(*args, **kwargs)
    if display_name == 'Unnamed resource':
        display_name = 'Unnamed file'
    return display_name
Esempio n. 4
0
def _export_resources_csv(zip_file, pkg_dict, request, response):
    file_names = {}
    for resource in pkg_dict['resources']:
        resource_name = h.resource_display_name(resource)
        if file_names.get(resource_name):
            resource_name = u'%s_%s' % (resource_name, resource['id'])
        else:
            file_names[resource_name] = True

        rc_filename = to_utf8_str('%s.csv' % resource_name)
        output = export_dict_to_csv(resource)
        zip_file.writestr(rc_filename, output)
Esempio n. 5
0
def _export_resources_json(zip_file, pkg_dict, request, response):
    file_names = {}
    for resource in pkg_dict['resources']:
        resource_name = h.resource_display_name(resource)
        if file_names.get(resource_name):
            resource_name = u'%s_%s' % (resource_name, resource['id'])
        else:
            file_names[resource_name] = True

        rc_filename = u'%s.json' % resource_name
        zip_file.writestr(
            rc_filename.encode('utf-8'),
            json.dumps(resource, indent=4, ensure_ascii=False).encode('utf-8'))
def get_snippet_resource(activity, detail):
#    return h.resource_link(detail['data']['resource'],
#                           activity['data']['package']['id'])
    return h.resource_display_name(detail['data']['resource'])
Esempio n. 7
0
 def _resource_display_name(self, resource_dict):
     """ taken from helpers.resource_display_name """
     value = helpers.resource_display_name(resource_dict)
     return value if value != _("Unnamed resource") else _(
         "Additional Info")
Esempio n. 8
0
def resource_display_name_clean(resource_dict):
    raw_name = resource_display_name(resource_dict)
    return raw_name.strip()
Esempio n. 9
0
File: plugin.py Progetto: haphut/ytp
 def _resource_display_name(self, resource_dict):
     """ taken from helpers.resource_display_name """
     value = helpers.resource_display_name(resource_dict)
     return value if value != _("Unnamed resource") else _("Additional Info")