def annotate_event(ev, key, ts=None, namespace=None, **kwargs):
ann = {}<EOL>if ts is None:<EOL><INDENT>ts = time.time()<EOL><DEDENT>ann["<STR_LIT>"] = ts<EOL>ann["<STR_LIT:key>"] = key<EOL>if namespace is None and "<STR_LIT>" in os.environ:<EOL><INDENT>namespace = "<STR_LIT>".format(<EOL>os.environ.get("<STR_LIT>"),<EOL>os.environ.get("<STR_LIT>"),<EOL>os.environ.get("<STR_LIT>"))<EOL><DEDENT>if namespace is not None:<EOL><INDENT>ann["<STR_LIT>"] = namespace<EOL><DEDENT>ann.update(kwargs)<EOL>_humilis = ev.get("<STR_LIT>", {})<EOL>if not _humilis:<EOL><INDENT>ev["<STR_LIT>"] = {"<STR_LIT>": [ann]}<EOL><DEDENT>else:<EOL><INDENT>ev["<STR_LIT>"]["<STR_LIT>"] = _humilis.get("<STR_LIT>", [])<EOL>delete_annotations(ev, key)<EOL>ev["<STR_LIT>"]["<STR_LIT>"].append(ann)<EOL><DEDENT>return ev<EOL>
Add an annotation to an event.