From c69c10181ee6d046d80148cda7ad0d5df8d2cd05 Mon Sep 17 00:00:00 2001 From: programthink Date: Tue, 1 Mar 2016 11:35:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=BC=96=E8=AF=91=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=20(=E5=A4=84=E7=90=86=20other=5Fnames=20=E5=B1=9E?= =?UTF-8?q?=E6=80=A7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/make.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/bin/make.py b/bin/make.py index c195cf9..32fd69c 100755 --- a/bin/make.py +++ b/bin/make.py @@ -192,25 +192,32 @@ digraph %s else : 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'(%s)' % (other_names,) if other_names else u'' + def _dot_node(self, node_id) : node = Node.all[node_id] template = u'''\t%s [shape="%s", color="%s", ''' \ u'''label=<''' \ u'''''' \ + u'''%s''' \ u'''''' \ u'''
%s%s
%s
%s
>];\n''' portrait = u'../data/person/%s/portrait.png' % (node_id,) - if os.path.exists(portrait) : - portrait = u'' % portrait - else : - portrait = u'' + portrait = u'' % (portrait,) if os.path.exists(portrait) else u'' - return template % (node.name, + return template % (node.id, u'box' if u'person'==node.type else u'ellipse', self._node_color(node), node.name, (u'' if node.birth==u'N/A' else u' [%s]'%node.birth), + self._other_names(node), portrait, node.desc.replace(u'\n', u'
'))