-
Notifications
You must be signed in to change notification settings - Fork 0
/
__main__.py
53 lines (38 loc) · 1.46 KB
/
__main__.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
50
51
52
53
#main.py
import yaml
import os
from networkx.readwrite import json_graph
from extractElements import extractElements
from create_graph import CreateGraph
current_dir = os.path.dirname(__file__)
print("Current directory: ", current_dir)
config_file = os.path.join(current_dir, 'config.yaml')
with open(config_file) as f:
config = yaml.load(f, Loader=yaml.FullLoader)
try:
format = config['inputmodels']['format']
metamodelpath = config['inputmodels']['metamodelpath']
modelpath = config['inputmodels']['modelspath']
output = config['output']
filters = config['adaptations']['metamodels']['packages']['ecore']['uri']['http://www.eclipse.org/emf/2002/Ecore']
# print("classes", filters)
print(format)
print(metamodelpath)
print(modelpath)
except KeyError:
print("Section not found in YAML file")
csvpath = modelpath.replace("models", "csvfiles")
if not os.path.exists(csvpath):
graphinstance = extractElements(modelpath, metamodelpath)
graph = CreateGraph(csvpath,filters)
if output =="NetworkX":
graphs = graph.model2HomoGraph()
graphs_list = list(graphs.values())
for graph in graphs_list:
linkdata = json_graph.node_link_data(graph)
print("grgaph is:",linkdata)
elif output =="PyG":
print("maiiiiiiiiiiin heterograph is", graph.model2heterograph())
# input_file = config['input']
# output_file = config['output']
# extract(input_file, output_file)