code: def _get_template(self, event, ctype, fields):
          
          from os import path
          template = path.join(self.server.dirname, "templates", "{}.{}".format(event, ctype))
          contents = None
          
          if path.isfile(template):
              with open(template) as f:
                  #The templates are very small, so we don't need to worry about the file size.
                  contents = f.read()
              for field, value in fields.items():
                  contents = contents.replace(field, value)
          else:
              raise ValueError("The event '{}' is not supported or ".format(event) +
                               "the template file ({}) is missing.".format(template))
          return contents
docs: Gets the contents of the template for the specified event and type
          with all the fields replaced.
          
          :arg event: one of ['start', 'error', 'success', 'timeout', 'failure'].
          :arg ctype: one of ["txt", "html"] specifying which template to use.
          :arg fields: a dictionary of fields and their replacement values to
            insert.