Skip to content

Instantly share code, notes, and snippets.

@dwcaraway
Created January 28, 2014 05:17
Show Gist options
  • Save dwcaraway/8662633 to your computer and use it in GitHub Desktop.
Save dwcaraway/8662633 to your computer and use it in GitHub Desktop.
this is causing formats like application/json to be forced into string JSON
def _unified_resource_format(format_):
''' Convert resource formats into a more uniform set.
eg .json, json, JSON, text/json all converted to JSON.'''
format_clean = format_.lower().split('/')[-1].replace('.', '')
formats = {
'csv' : 'CSV',
'zip' : 'ZIP',
'pdf' : 'PDF',
'xls' : 'XLS',
'json' : 'JSON',
'kml' : 'KML',
'xml' : 'XML',
'shape' : 'SHAPE',
'rdf' : 'RDF',
'txt' : 'TXT',
'text' : 'TEXT',
'html' : 'HTML',
}
if format_clean in formats:
format_new = formats[format_clean]
else:
format_new = format_.lower()
return format_new
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment