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:
53 if "actions" in token:
54 for at in token["actions"]:
55 action = EdgeAction.Create(at)
59 edge.actionList.append(action)
66 def Apply(self, first, second):
69 for i in range(len(self.actionList)):
70 act = self.actionList[i]
72 if act.FromStartObject == True:
73 exp.append(first.GetValue(act.FromExpression))
74 elif act.FromStartObject == False:
75 exp.append(second.GetValue(act.FromExpression))
77 exp.append(act.FromExpression)
79 for i in range(len(exp)):
80 act = self.actionList[i]
83 first.SetFieldAuto(act.ToExpression, exp[i])
85 second.SetFieldAuto(act.ToExpression, exp[i])
88 return self.actionList
91 return self.Start + "_" + self.End