def newline_separated_statements(args): transformed = [] for arg in args: if isinstance(arg, list): transformed.append(arg[0]) transformed = list(flatten_list(transformed)) return transformed
def __generate_tree_guess(self): self.req_syntax_tree.create_tree(replace_characters(self.requirement.description)) transformed = self.req_transformer.transform(self.req_syntax_tree.tree) req = list(flatten_list(transformed.children)) if isinstance(req[0], dict): logic = req[0]['logic'] if_part = req[0]['if_part'] then_part = req[0]['then_part'] print(logic) print(if_part) print(then_part) else: print(req) var1 = "" var2 = "" scope = 'GLOBALLY' scoped_pattern = ScopedPattern( Scope[scope], Pattern(name='BoundedResponse') ) mapping = { 'R': "%s" % var1, 'S': "%s" % var2, 'T': 'MAX_TIME' } return scoped_pattern, mapping
def test_transform(self): s = ReqSyntaxTree() transformer = ReqTransformer() for i, req in enumerate(reqs): s.create_tree(req) new_tree = transformer.transform(s.tree) flattend_list = list(flatten_list(new_tree.children)) self.assertEqual(flattend_list, results[i])
def comparison(args): lhs = args[0] rhs = args[2].replace('"', '').upper().strip() if rhs == 'TRUE': transformed = "%s" % lhs elif rhs == 'FALSE': transformed = "!%s" % lhs else: transformed = " ".join(list(flatten_list(args))) return transformed
def statement_in_parentheses(args): transformed = list(flatten_list(args)) transformed = " ".join(transformed) return transformed
def arithmetic(args): transformed = " ".join(list(flatten_list(args))) return transformed
def else_part(args): return {'else_part': list(flatten_list(args))}
def then_part(args): return {'then_part': list(flatten_list(args))}
def if_part(self, args): return {'if_part': list(flatten_list(args)), 'logic': self.current_logic}
def assign(args): transformed = " ".join(list(flatten_list(args))) return transformed