• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python reader.jsonToAst函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: testFloat

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


示例17: testDouble

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


示例18: testDefineFunction

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


示例19: testBase64

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


示例20: testCallFunction

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python util.callfcn函数代码示例发布时间:2022-05-27
下一篇:
Python genpy.PFAEngine类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap