def test_roundup(): comm = { 'x': [], 'y': [], 'z': [], 'a': ['1', '2', '3'], 'b': ['thing\''], 'c': ['many things'], 'd': ['strange \\ things'], } assert parse(dumps(parse(dumps(comm)))) == comm
def update(self, ea, key, value): """Add key=values to comm string at EA.""" cmt = idaapi.get_cmt(ea, 0) comm = cmt and bap_comment.parse(cmt) or {} values = comm.setdefault(key, []) if value and value != '()' and value not in values: values.append(value) idaapi.set_cmt(ea, bap_comment.dumps(comm), 0)
def visit_line(self, line): comm = {} for address in line.extract_addresses(): idacomm = idc.Comment(address) newcomm = idacomm and bap_comment.parse(idacomm) or {} union(comm, newcomm) if comm: line.widget.line += COLOR_START line.widget.line += bap_comment.dumps(comm) line.widget.line += COLOR_END
def test_quotation(): data = 'BAP: chars="{\\\"a\\\", \\\"b\\\", \\\"c\\\"}"' assert parse(data) == {'chars': ['{"a", "b", "c"}']} assert parse(data) == parse(dumps(parse(data)))
def test_dumps(): assert 'BAP:' in dumps({'hello': []}) assert dumps({'hello': ['cruel', 'world'], 'nice': [], 'thing': []}) == \ 'BAP: nice,thing hello=cruel,world' assert dumps({'hello': ["world'"]}) == 'BAP: hello="world\'"'