def create_message(self, rootdict, path, error, add_comments):
if not path:<EOL><INDENT>d = rootdict<EOL>key = d["<STR_LIT>"]<EOL><DEDENT>elif isinstance(path[-<NUM_LIT:1>], int):<EOL><INDENT>d = utils.findkey(rootdict, *path)<EOL>key = d["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>key = path[-<NUM_LIT:1>]<EOL>d = utils.findkey(rootdict, *path[:-<NUM_LIT:1>])<EOL><DEDENT>error_message = "<STR_LIT>".format(key.upper())<EOL>if add_comments:<EOL><INDENT>if "<STR_LIT>" not in d:<EOL><INDENT>d["<STR_LIT>"] = OrderedDict()<EOL><DEDENT>d["<STR_LIT>"][key] = "<STR_LIT>".format(error_message)<EOL><DEDENT>error_message = {"<STR_LIT:error>": error.message,<EOL>"<STR_LIT:message>": error_message}<EOL>if "<STR_LIT>" in d:<EOL><INDENT>if not path:<EOL><INDENT>pd = d["<STR_LIT>"]<EOL><DEDENT>else:<EOL><INDENT>pd = d["<STR_LIT>"][key]<EOL><DEDENT>error_message["<STR_LIT>"] = pd.get("<STR_LIT>")<EOL>error_message["<STR_LIT>"] = pd.get("<STR_LIT>")<EOL><DEDENT>return error_message<EOL>
Add a validation comment to the dictionary
path is the path to the error object, it can be empty if the error is in the root object
http://python-jsonschema.readthedocs.io/en/latest/errors/#jsonschema.exceptions.ValidationError.absolute_path
It can also reference an object in a list e.g. [u'layers', 0]

Unfortunately it is not currently possible to get the name of the failing property from the
JSONSchema error object, even though it is in the error message.
See https://github.com/Julian/jsonschema/issues/119