更新编译脚本 (处理 other_names 属性)

This commit is contained in:
programthink 2016-03-01 11:35:52 +08:00
parent 97cf671b62
commit c69c10181e
1 changed files with 12 additions and 5 deletions

View File

@ -192,25 +192,32 @@ digraph %s
else : else :
return (u'blue' if u'M'==node.sex else u'red') return (u'blue' if u'M'==node.sex else u'red')
def _other_names(self, node) :
other_names = ''
if u'person'==node.type and node.other_names :
other_names = u', '.join(['%s:%s' % (k,v) for k,v in node.other_names.items()])
elif u'company'==node.type and node.full_name :
other_names = node.full_name
return u'<tr><td>(%s)</td></tr>' % (other_names,) if other_names else u''
def _dot_node(self, node_id) : def _dot_node(self, node_id) :
node = Node.all[node_id] node = Node.all[node_id]
template = u'''\t%s [shape="%s", color="%s", ''' \ template = u'''\t%s [shape="%s", color="%s", ''' \
u'''label=<<table border="0" cellborder="0">''' \ u'''label=<<table border="0" cellborder="0">''' \
u'''<tr><td>%s%s</td></tr>''' \ u'''<tr><td>%s%s</td></tr>''' \
u'''%s''' \
u'''<tr><td>%s</td></tr>''' \ u'''<tr><td>%s</td></tr>''' \
u'''<tr><td>%s</td></tr></table>>];\n''' u'''<tr><td>%s</td></tr></table>>];\n'''
portrait = u'../data/person/%s/portrait.png' % (node_id,) portrait = u'../data/person/%s/portrait.png' % (node_id,)
if os.path.exists(portrait) : portrait = u'<img src="%s"/>' % (portrait,) if os.path.exists(portrait) else u''
portrait = u'<img src="%s"/>' % portrait
else :
portrait = u''
return template % (node.name, return template % (node.id,
u'box' if u'person'==node.type else u'ellipse', u'box' if u'person'==node.type else u'ellipse',
self._node_color(node), self._node_color(node),
node.name, node.name,
(u'' if node.birth==u'N/A' else u' [%s]'%node.birth), (u'' if node.birth==u'N/A' else u' [%s]'%node.birth),
self._other_names(node),
portrait, portrait,
node.desc.replace(u'\n', u'<br/>')) node.desc.replace(u'\n', u'<br/>'))