当前位置: 首页>>代码示例>>Python>>正文


Python reader.jsonToAst函数代码示例

本文整理汇总了Python中titus.reader.jsonToAst函数的典型用法代码示例。如果您正苦于以下问题:Python jsonToAst函数的具体用法?Python jsonToAst怎么用?Python jsonToAst使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了jsonToAst函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testCallWithFcnDef

    def testCallWithFcnDef(self):
        x = EngineConfig("test", Method.MAP, AvroInt(), AvroString(), [], [Call("sort", [Ref("array"), FcnDef([{"x": AvroInt()}, {"y": AvroString()}], AvroNull(), [LiteralNull()])])], [], {}, None, None, {}, {}, None, None, None, {}, {})
        y = jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"sort":["array",{"params": [{"x": "int"}, {"y": "string"}], "ret": "null", "do": [null]}]}]
}''')
        self.assertEqual(
        EngineConfig(
        "test",
        Method.MAP,
        AvroInt(),
        AvroString(),
        [],
        [Call("sort", [Ref("array"), FcnDef([{"x": AvroInt()}, {"y": AvroString()}], AvroNull(), [LiteralNull()])])],
        [],
        {},
        None,
        None,
        {},
        {},
        None,
        None,
        None,
        {},
        {}),
        jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"sort":["array",{"params": [{"x": "int"}, {"y": "string"}], "ret": "null", "do": [null]}]}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:33,代码来源:testJsonToAst.py

示例2: testCellSet

    def testCellSet(self):
        self.assertEqual(
        EngineConfig(
        "test",
        Method.MAP,
        AvroInt(),
        AvroString(),
        [],
        [CellTo("c", [], LiteralDouble(2.2))],
        [],
        {},
        None,
        None,
        {},
        {},
        None,
        None,
        None,
        {},
        {}),
        jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"cell":"c","to":2.2}]
}'''))
        self.assertEqual(
        EngineConfig(
        "test",
        Method.MAP,
        AvroInt(),
        AvroString(),
        [],
        [CellTo("c", [Ref("a"), LiteralInt(1), LiteralString("b")], LiteralDouble(2.2))],
        [],
        {},
        None,
        None,
        {},
        {},
        None,
        None,
        None,
        {},
        {}),
        jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"cell":"c","path":["a",1,{"string":"b"}],"to":2.2}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:51,代码来源:testJsonToAst.py

示例3: testLong

    def testLong(self):
        self.assertEqual(
        EngineConfig(
        "test",
        Method.MAP,
        AvroLong(),
        AvroString(),
        [],
        [LiteralLong(2)],
        [],
        {},
        None,
        None,
        {},
        {},
        None,
        None,
        None,
        {},
        {}),
        jsonToAst('''{
  "name": "test",
  "input": "long",
  "output": "string",
  "action": [{"long": 2}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例4: testDoUntil

    def testDoUntil(self):
        self.assertEqual(
          EngineConfig(
          "test",
          Method.MAP,
          AvroInt(),
          AvroString(),
          [],
          [DoUntil([Call("+", [LiteralInt(2), LiteralInt(2)])], LiteralBoolean(True))],
          [],
          {},
          None,
          None,
          {},
          {},
          None,
          None,
          None,
          {},
          {}),
          jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"do":[{"+":[2,2]}],"until":true}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例5: testSet

    def testSet(self):
        self.assertEqual(
        EngineConfig(
        "test",
        Method.MAP,
        AvroInt(),
        AvroString(),
        [],
        [SetVar({"x": LiteralInt(3), "y": LiteralInt(4)})],
        [],
        {},
        None,
        None,
        {},
        {},
        None,
        None,
        None,
        {},
        {}),
        jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"set":{"x":3,"y":4}}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例6: testNewArray

    def testNewArray(self):
        self.assertEqual(
        EngineConfig(
        "test",
        Method.MAP,
        AvroInt(),
        AvroString(),
        [],
        [NewArray([LiteralInt(1), LiteralInt(2), LiteralInt(3)], AvroArray(AvroInt()), AvroTypeBuilder())],
        [],
        {},
        None,
        None,
        {},
        {},
        None,
        None,
        None,
        {},
        {}),
        jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"new":[1,2,3],"type":{"type":"array","items":"int"}}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例7: testLiteral

    def testLiteral(self):
        self.assertEqual(
        EngineConfig(
        "test",
        Method.MAP,
        AvroInt(),
        AvroString(),
        [],
        [Literal(AvroRecord([AvroField("one", AvroInt()), AvroField("two", AvroDouble()), AvroField("three", AvroString())], "SimpleRecord"), '''{"one": 1, "two": 2.2, "three": "THREE"}''')],
        [],
        {},
        None,
        None,
        {},
        {},
        None,
        None,
        None,
        {},
        {}),
        jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"type":{"type":"record","name":"SimpleRecord","fields":[{"name":"one","type":"int"},{"name":"two","type":"double"},{"name":"three","type":"string"}]},"value":{"one":1,"two":2.2,"three":"THREE"}}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例8: testString

    def testString(self):
        self.assertEqual(
        EngineConfig(
        "test",
        Method.MAP,
        AvroInt(),
        AvroString(),
        [],
        [LiteralString("hello")],
        [],
        {},
        None,
        None,
        {},
        {},
        None,
        None,
        None,
        {},
        {}),
        jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"string": "hello"}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例9: testCell

    def testCell(self):
        self.assertEqual(
            EngineConfig(
            "test",
            Method.MAP,
            AvroInt(),
            AvroString(),
            [],
            [Call("+", [LiteralInt(2), LiteralInt(2)])],
            [],
            {},
            None,
            None,
            {"private": Cell(AvroArray(AvroString()), "[]", False, False, CellPoolSource.EMBEDDED)},
            {},
            None,
            None,
            None,
            {},
            {}),
            jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"+": [2, 2]}],
  "cells":{"private":{"type":{"type": "array", "items": "string"},"init":[],"shared":false,"rollback":false}}
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:27,代码来源:testJsonToAst.py

示例10: testLog

    def testLog(self):
        self.assertEqual(
          EngineConfig(
          "test",
          Method.MAP,
          AvroInt(),
          AvroString(),
          [],
          [Log([LiteralString("hello")], None),
           Log([LiteralString("hello")], "DEBUG"),
           Log([Call("+", [LiteralInt(2), LiteralInt(2)])], None)],
          [],
          {},
          None,
          None,
          {},
          {},
          None,
          None,
          None,
          {},
          {}),
          jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"log":[{"string":"hello"}]},
             {"log":[{"string":"hello"}],"namespace":"DEBUG"},
             {"log":[{"+":[2,2]}]}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:30,代码来源:testJsonToAst.py

示例11: testError

    def testError(self):
        self.assertEqual(
          EngineConfig(
          "test",
          Method.MAP,
          AvroInt(),
          AvroString(),
          [],
          [Error("hello", None), Error("hello", -3)],
          [],
          {},
          None,
          None,
          {},
          {},
          None,
          None,
          None,
          {},
          {}),
          jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"error":"hello"}, {"error":"hello","code":-3}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例12: testCast

    def testCast(self):
        self.assertEqual(
          EngineConfig(
          "test",
          Method.MAP,
          AvroInt(),
          AvroString(),
          [],
          [CastBlock(LiteralInt(3), [CastCase(AvroString(), "x", [Ref("x")]), CastCase(AvroInt(), "x", [Ref("x")])], True)],
          [],
          {},
          None,
          None,
          {},
          {},
          None,
          None,
          None,
          {},
          {}),
          jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"cast":{"int":3},"cases":[{"as":"string","named":"x","do":["x"]},{"as":"int","named":"x","do":["x"]}],"partial":true}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例13: testForkeyval

    def testForkeyval(self):
        self.assertEqual(
          EngineConfig(
          "test",
          Method.MAP,
          AvroInt(),
          AvroString(),
          [],
          [Forkeyval("k", "v", Literal(AvroMap(AvroInt()), '''{"one": 1, "two": 2, "three": 3}'''), [Ref("k")])],
          [],
          {},
          None,
          None,
          {},
          {},
          None,
          None,
          None,
          {},
          {}),
          jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"forkey":"k","forval":"v","in":{"type":{"type":"map","values":"int"},"value":{"one":1,"two":2,"three":3}},"do":["k"]}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例14: testForeach

    def testForeach(self):
        self.assertEqual(
          EngineConfig(
          "test",
          Method.MAP,
          AvroInt(),
          AvroString(),
          [],
          [Foreach("x", Literal(AvroArray(AvroInt()), '''[1, 2, 3]'''), [Ref("x")], False)],
          [],
          {},
          None,
          None,
          {},
          {},
          None,
          None,
          None,
          {},
          {}),
          jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"foreach":"x","in":{"type":{"type":"array","items":"int"},"value":[1,2,3]},"do":["x"],"seq":false}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py

示例15: testFor

    def testFor(self):
        self.assertEqual(
          EngineConfig(
          "test",
          Method.MAP,
          AvroInt(),
          AvroString(),
          [],
          [For({"i": LiteralInt(0)}, Call("<", [Ref("i"), LiteralInt(10)]), {"i": Call("+", [Ref("i"), LiteralInt(1)])}, [Ref("i")], False)],
          [],
          {},
          None,
          None,
          {},
          {},
          None,
          None,
          None,
          {},
          {}),
          jsonToAst('''{
  "name": "test",
  "input": "int",
  "output": "string",
  "action": [{"for":{"i":0},"while":{"<":["i",10]},"step":{"i":{"+":["i",1]}},"do":["i"]}]
}'''))
开发者ID:nkhuyu,项目名称:hadrian,代码行数:26,代码来源:testJsonToAst.py


注:本文中的titus.reader.jsonToAst函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。