1 # Copyright (c) 2022 Intel and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 from EdgeAction import *
26 f = open(jsonfile, "r", encoding="utf-8")
32 if token["type"] != "edge":
37 startNodes = token["start"]
38 endNodes = token["end"]
40 if startNodes == None or endNodes == None:
43 startTokens = startNodes.split(",")
44 endTokens = endNodes.split(",")
46 for start in startTokens:
54 if "actions" in token:
55 for at in token["actions"]:
56 action = EdgeAction.Create(at)
60 edge.actionList.append(action)
67 def Apply(self, first, second):
70 for i in range(len(self.actionList)):
71 act = self.actionList[i]
73 if act.FromStartObject == True:
74 exp.append(first.GetValue(act.FromExpression))
75 elif act.FromStartObject == False:
76 exp.append(second.GetValue(act.FromExpression))
78 exp.append(act.FromExpression)
80 for i in range(len(exp)):
81 act = self.actionList[i]
84 first.SetFieldAuto(act.ToExpression, exp[i])
86 second.SetFieldAuto(act.ToExpression, exp[i])
89 return self.actionList
92 return self.Start + "_" + self.End