@core_helper
def resource_formats():
 global _RESOURCE_FORMATS
 if (not _RESOURCE_FORMATS):
  _RESOURCE_FORMATS = {}
  format_file_path = config.get('ckan.resource_formats')
  if (not format_file_path):
   format_file_path = os.path.join(os.path.dirname(os.path.realpath(ckan.config.__file__)), 'resource_formats.json')
  with open(format_file_path) as format_file:
   try:
    file_resource_formats = json.loads(format_file.read())
   except ValueError as e:
    raise ValueError(('Invalid JSON syntax in %s: %s' % (format_file_path, e)))
   for format_line in file_resource_formats:
    if (format_line[0] == '_comment'):
     continue
    line = [format_line[2], format_line[0], format_line[1]]
    alternatives = (format_line[3] if (len(format_line) == 4) else [])
    for item in (line + alternatives):
     if item:
      item = item.lower()
      if ((item in _RESOURCE_FORMATS) and (_RESOURCE_FORMATS[item] != line)):
       raise ValueError(('Duplicate resource format identifier in %s: %s' % (format_file_path, item)))
      _RESOURCE_FORMATS[item] = line
 return _RESOURCE_FORMATS

@ core_helper def resource_formats ( ) : global _RESOURCE_FORMATS if ( not _RESOURCE_FORMATS ) : _RESOURCE_FORMATS = { } format_file_path = config . get ( 'ckan.resource_formats' ) if ( not format_file_path ) : format_file_path = os . path . join ( os . path . dirname ( os . path . realpath ( ckan . config . __file__ ) ) , 'resource_formats.json' ) with open ( format_file_path ) as format_file : try : file_resource_formats = json . loads ( format_file . read ( ) ) except ValueError as e : raise ValueError ( ( 'Invalid JSON syntax in %s: %s' % ( format_file_path , e ) ) ) for format_line in file_resource_formats : if ( format_line [ 0 ] == '_comment' ) : continue line = [ format_line [ 2 ] , format_line [ 0 ] , format_line [ 1 ] ] alternatives = ( format_line [ 3 ] if ( len ( format_line ) == 4 ) else [ ] ) for item in ( line + alternatives ) : if item : item = item . lower ( ) if ( ( item in _RESOURCE_FORMATS ) and ( _RESOURCE_FORMATS [ item ] != line ) ) : raise ValueError ( ( 'Duplicate resource format identifier in %s: %s' % ( format_file_path , item ) ) ) _RESOURCE_FORMATS [ item ] = line return _RESOURCE_FORMATS
returns the resource formats as a dict .