MCPcopy
hub / github.com/programthink/zhao / Builder

Class Builder

bin/make.py:256–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254
255
256class Builder :
257 def __init__(self) :
258 Node.init()
259 Relation.init()
260 Family.init()
261
262 def _mkdir(self, name) :
263 if os.path.exists(name) :
264 shutil.rmtree(name)
265 os.mkdir(name)
266
267 def _exec(self, cmd) :
268 print(cmd)
269 return os.system(cmd.encode(u'utf-8'))
270
271 def do(self, file_type) :
272 os.chdir(u'../download/')
273 self._mkdir(u'dot')
274 self._mkdir(file_type)
275 n = 0
276 for graph in _load_yaml(u'../data/graph.yaml') :
277 n += 1
278 name = u'%02d-%s' % (n, graph[u'name'])
279 dot_file = u'./dot/%s.dot' % (name,)
280 output_file = u'./%s/%s.%s' % (file_type, name, file_type)
281
282 with open(dot_file, u'wb') as f :
283 f.write(Graph(graph).dump().encode(u'utf-8'))
284
285 cmd = u'dot "%s" -T%s -o"%s"' % (dot_file, file_type, output_file)
286 if self._exec(cmd) != 0 :
287 _raise_err(u'Make "%s" failed!', dot_file)
288 return 0
289
290
291if '__main__' == __name__ :

Callers 1

make.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected