-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathAnnotation Import.py
More file actions
executable file
·34 lines (30 loc) · 980 Bytes
/
Annotation Import.py
File metadata and controls
executable file
·34 lines (30 loc) · 980 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# vim: tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab:
# Copyright: (c)2015 Chris Kuethe <chris.kuethe+github@gmail.com>
# License: Perl Artistic <http://dev.perl.org/licenses/artistic.html>
# Description: imports address labels and comments from a JSON file
import json
doc = Document.getCurrentDocument()
infile = doc.askFile('Select annotation file', None, None)
if infile is not None:
f = open(infile, "r")
symtab = json.loads(f.read())
f.close()
tseg = -1
seg = None
for addr in symtab.keys():
try:
a = symtab[addr]
addr = int(addr)
if ((a['seg'] != tseg) or (seg is None)):
tseg = a['seg']
seg = doc.getSegment(a['seg'])
if a['name'] is not None:
seg.setNameAtAddress(addr, a['name'])
if a['comm'] is not None:
seg.setCommentAtAddress(addr, a['comm'])
if a['icom'] is not None:
seg.setInlineCommentameAtAddress(addr, a['icom'])
except Exception:
pass
doc.log("loaded annotations from %s" % infile)
doc.refreshView()