def guess_mime_type(content, deftype):
 starts_with_mappings = {'#include': 'text/x-include-url', '#!': 'text/x-shellscript', '#cloud-config': 'text/cloud-config', '#upstart-job': 'text/upstart-job', '#part-handler': 'text/part-handler', '#cloud-boothook': 'text/cloud-boothook'}
 rtype = deftype
 for (possible_type, mimetype) in starts_with_mappings.items():
  if content.startswith(possible_type):
   rtype = mimetype
   break
 return rtype

def guess_mime_type ( content , deftype ) : starts_with_mappings = { '#include' : 'text/x-include-url' , '#!' : 'text/x-shellscript' , '#cloud-config' : 'text/cloud-config' , '#upstart-job' : 'text/upstart-job' , '#part-handler' : 'text/part-handler' , '#cloud-boothook' : 'text/cloud-boothook' } rtype = deftype for ( possible_type , mimetype ) in starts_with_mappings . items ( ) : if content . startswith ( possible_type ) : rtype = mimetype break return rtype
description: guess the mime type of a block of text .