Created
January 28, 2014 05:17
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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