-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
49 lines (34 loc) · 1.18 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from __future__ import unicode_literals
import os
from os.path import dirname, join
from textx import metamodel_from_file
from textx.export import metamodel_export, model_export
this_folder = dirname(__file__)
#print(this_folder)
class SimpleType(object):
def __init__(self, parent, name):
self.parent = parent
self.name = name
def __str__(self):
return self.name
def get_metamodel():
simple_types = {
'int': SimpleType(None, 'int'),
'String': SimpleType(None, 'String'),
'Long': SimpleType(None, 'Long'),
'boolean': SimpleType(None, 'boolean')
}
metamodel = metamodel_from_file('meta-model/term.tx',
classes=[SimpleType],
builtins=simple_types)
return metamodel
def main():
mm = get_metamodel()
dot_folder = join(this_folder, 'dotexport')
if not os.path.exists(dot_folder):
os.mkdir(dot_folder)
metamodel_export(mm, join(dot_folder,'term.dot'))
model = mm.model_from_file('model/model.term')
model_export(model, join(dot_folder, 'model.dot'))
if __name__ == "__main__":
main()