| 21 | |
| 22 | |
| 23 | class Node : |
| 24 | all = {} |
| 25 | keys = [] |
| 26 | |
| 27 | @classmethod |
| 28 | def init(cls) : |
| 29 | Node.all = {} |
| 30 | Node.keys = [] |
| 31 | |
| 32 | for node_type in [u'person', u'company'] : |
| 33 | for node_id in os.listdir(u'../data/' + node_type) : |
| 34 | yaml_file = u'../data/%s/%s/brief.yaml' % (node_type, node_id) |
| 35 | node = Node(_load_yaml(yaml_file), node_id, node_type) |
| 36 | if node_id in Node.all : |
| 37 | _raise_err(u'Node id conflict: "%s"!', node_id) |
| 38 | |
| 39 | Node.all[node_id] = node |
| 40 | Node.keys.append(node_id) |
| 41 | print(u'Node number: %d' % len(Node.all)) |
| 42 | |
| 43 | |
| 44 | def __init__(self, yaml, node_id, type) : |
| 45 | self.id = node_id |
| 46 | self.type = type |
| 47 | self.name = yaml[u'name'] |
| 48 | if u'other_names' in yaml : # person |
| 49 | self.other_names = yaml[u'other_names'] |
| 50 | if u'sex' in yaml : # person |
| 51 | self.sex = yaml[u'sex'] |
| 52 | if u'full_name' in yaml : # company |
| 53 | self.full_name = yaml[u'full_name'] |
| 54 | self.birth = yaml[u'birth'] |
| 55 | self.death = yaml[u'death'] |
| 56 | self.desc = yaml[u'desc'] |
| 57 | self.links = yaml[u'links'] |
| 58 | |
| 59 | |
| 60 | |