MCPcopy Index your code
hub / github.com/programthink/zhao / Relation

Class Relation

bin/make.py:61–92  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

59
60
61class Relation :
62 all = {}
63 keys = []
64
65 @classmethod
66 def init(cls) :
67 for family_id in os.listdir(u'../data/family/') :
68 family_id = family_id.replace(u'.yaml', u'')
69 yaml_file = u'../data/family/%s.yaml' % (family_id,)
70 if family_id not in Node.all :
71 _raise_err(u'Invalid family name: "%s"!', family_id)
72
73 yaml = _load_yaml(yaml_file)
74 for lst in yaml[u'relations'] :
75 relation = Relation(lst)
76 Relation.all[relation.name] = relation
77 Relation.keys.append(relation.name)
78 print(u'Relation number: %d' % len(Relation.all))
79
80
81 def __init__(self, lst) :
82 self.node_from = lst[0]
83 self.node_to = lst[1]
84 self.desc = lst[2]
85 self.name = self.node_from + u'->' + self.node_to
86
87 if self.name in Relation.all :
88 _raise_err(u'Relation name conflict: "%s"!', self.name)
89 if self.node_from not in Node.all :
90 _raise_err(u'Invalid relation "from" attr: "%s"!', self.node_from)
91 if self.node_to not in Node.all :
92 _raise_err(u'Invalid relation "to" attr": "%s"!', self.node_to)
93
94
95

Callers 1

initMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected