parameters: (filepath, mimetype=None)
return_statement: return data_uri
docstring: Given a file at *filepath*, return that file as a data URI.
  
      Raises a `MimeTypeFail` exception if the mimetype could not be guessed.
docstring_summary: Given a file at *filepath*, return that file as a data URI.
docstring_tokens: Given a file at * filepath * return that file as a data URI .
function: def create_data_uri(filepath, mimetype=None):
      """
      Given a file at *filepath*, return that file as a data URI.
  
      Raises a `MimeTypeFail` exception if the mimetype could not be guessed.
      """
      import base64
      if not mimetype:
          mimetype = mimetypes.guess_type(filepath)[0]
      if not mimetype:
          raise MimeTypeFail("Could not guess mime type of: %s" % filepath)
      with io.open(filepath, mode='rb') as f:
          data = f.read()
      encoded = base64.b64encode(data).decode('ascii').replace('\n', '')
      if len(encoded) > 65000:
          logging.warn(
              "WARNING: Data URI > 65,000 characters.  You're pushing it buddy!")
      data_uri = "data:%s;base64,%s" % (mimetype, encoded)
      return data_uri
function_tokens: def create_data_uri ( filepath , mimetype = None ) : import base64 if not mimetype : mimetype = mimetypes . guess_type ( filepath ) [ 0 ] if not mimetype : raise MimeTypeFail ( "Could not guess mime type of: %s" % filepath ) with io . open ( filepath , mode = 'rb' ) as f : data = f . read ( ) encoded = base64 . b64encode ( data ) . decode ( 'ascii' ) . replace ( '\n' , '' ) if len ( encoded ) > 65000 : logging . warn ( "WARNING: Data URI > 65,000 characters.  You're pushing it buddy!" ) data_uri = "data:%s;base64,%s" % ( mimetype , encoded ) return data_uri