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


Python Schema.extract方法代码示例

本文整理汇总了Python中txaws.server.schema.Schema.extract方法的典型用法代码示例。如果您正苦于以下问题:Python Schema.extract方法的具体用法?Python Schema.extract怎么用?Python Schema.extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在txaws.server.schema.Schema的用法示例。


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

示例1: test_extract_complex

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
    def test_extract_complex(self):
        """L{Schema} can cope with complex schemas."""
        schema = Schema(
            Unicode("GroupName"),
            RawStr("IpPermissions.n.IpProtocol"),
            Integer("IpPermissions.n.FromPort"),
            Integer("IpPermissions.n.ToPort"),
            Unicode("IpPermissions.n.Groups.m.UserId", optional=True),
            Unicode("IpPermissions.n.Groups.m.GroupName", optional=True))

        arguments, _ = schema.extract(
            {"GroupName": "Foo",
             "IpPermissions.1.IpProtocol": "tcp",
             "IpPermissions.1.FromPort": "1234",
             "IpPermissions.1.ToPort": "5678",
             "IpPermissions.1.Groups.1.GroupName": "Bar",
             "IpPermissions.1.Groups.2.GroupName": "Egg"})

        self.assertEqual(u"Foo", arguments.GroupName)
        self.assertEqual(1, len(arguments.IpPermissions))
        self.assertEqual(1234, arguments.IpPermissions[0].FromPort)
        self.assertEqual(5678, arguments.IpPermissions[0].ToPort)
        self.assertEqual(2, len(arguments.IpPermissions[0].Groups))
        self.assertEqual("Bar", arguments.IpPermissions[0].Groups[0].GroupName)
        self.assertEqual("Egg", arguments.IpPermissions[0].Groups[1].GroupName)
开发者ID:antisvin,项目名称:txAWS,代码行数:27,代码来源:test_schema.py

示例2: test_optional_list

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_optional_list(self):
     """
     The default value of an optional L{List} is C{[]}.
     """
     schema = Schema(List("names", Unicode(), optional=True))
     arguments, _ = schema.extract({})
     self.assertEqual([], arguments.names)
开发者ID:antisvin,项目名称:txAWS,代码行数:9,代码来源:test_schema.py

示例3: test_add_single_extra_schema_item

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_add_single_extra_schema_item(self):
     """New Parameters can be added to the Schema."""
     schema = Schema(Unicode("name"))
     schema = schema.extend(Unicode("computer"))
     arguments, _ = schema.extract({"name": "value", "computer": "testing"})
     self.assertEqual(u"value", arguments.name)
     self.assertEqual("testing", arguments.computer)
开发者ID:antisvin,项目名称:txAWS,代码行数:9,代码来源:test_schema.py

示例4: test_schema_conversion_optional_list

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_schema_conversion_optional_list(self):
     """
     Backwards-compatibility conversions maintains optional-ness of lists.
     """
     schema = Schema(Unicode("foos.N", optional=True))
     arguments, _ = schema.extract({})
     self.assertEqual([], arguments.foos)
开发者ID:antisvin,项目名称:txAWS,代码行数:9,代码来源:test_schema.py

示例5: test_extract_with_single_numbered

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_extract_with_single_numbered(self):
     """
     L{Schema.extract} can handle a single parameter with a numbered value.
     """
     schema = Schema(Unicode("name.n"))
     arguments, _ = schema.extract({"name.0": "Joe"})
     self.assertEqual("Joe", arguments.name[0])
开发者ID:ArtRichards,项目名称:txaws,代码行数:9,代码来源:test_schema.py

示例6: test_extract_structure_with_optional

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_extract_structure_with_optional(self):
     """L{Schema.extract} can handle optional parameters."""
     schema = Schema(
         Structure(
             "struct",
             fields={"name": Unicode(optional=True, default="radix")}))
     arguments, _ = schema.extract({"struct": {}})
     self.assertEqual(u"radix", arguments.struct.name)
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:test_schema.py

示例7: test_extract_with_rest

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_extract_with_rest(self):
     """
     L{Schema.extract} stores unknown parameters in the 'rest' return
     dictionary.
     """
     schema = Schema()
     _, rest = schema.extract({"name": "value"})
     self.assertEqual(rest, {"name": "value"})
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:test_schema.py

示例8: test_extract

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_extract(self):
     """
     L{Schema.extract} returns an L{Argument} object whose attributes are
     the arguments extracted from the given C{request}, as specified.
     """
     schema = Schema(Unicode("name"))
     arguments, _ = schema.extract({"name": "value"})
     self.assertEqual("value", arguments.name)
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:test_schema.py

示例9: test_extract_with_numbered

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_extract_with_numbered(self):
     """
     L{Schema.extract} can handle parameters with numbered values.
     """
     schema = Schema(Unicode("name.n"))
     arguments, _ = schema.extract({"name.0": "Joe", "name.1": "Tom"})
     self.assertEqual("Joe", arguments.name[0])
     self.assertEqual("Tom", arguments.name[1])
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:test_schema.py

示例10: test_extract_with_non_numbered_template

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_extract_with_non_numbered_template(self):
     """
     L{Schema.extract} accepts a single numbered argument even if the
     associated template is not numbered.
     """
     schema = Schema(Unicode("name"))
     arguments, _ = schema.extract({"name.1": "foo"})
     self.assertEqual("foo", arguments.name)
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:test_schema.py

示例11: test_extract_with_single_numbered

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_extract_with_single_numbered(self):
     """
     L{Schema.extract} can handle an un-numbered argument passed in to a
     numbered parameter.
     """
     schema = Schema(Unicode("name.n"))
     arguments, _ = schema.extract({"name": "Joe"})
     self.assertEqual("Joe", arguments.name[0])
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:test_schema.py

示例12: test_extract_with_mixed

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_extract_with_mixed(self):
     """
     L{Schema.extract} stores in the rest result all numbered parameters
     given without an index.
     """
     schema = Schema(Unicode("name.n"))
     _, rest = schema.extract({"name": "foo", "name.1": "bar"})
     self.assertEqual(rest, {"name": "foo"})
开发者ID:ArtRichards,项目名称:txaws,代码行数:10,代码来源:test_schema.py

示例13: test_structure

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_structure(self):
     """
     L{Schema}s with L{Structure} parameters can have arguments extracted.
     """
     schema = Schema(Structure("foo", {"a": Integer(), "b": Integer()}))
     arguments, _ = schema.extract({"foo.a": "1", "foo.b": "2"})
     self.assertEqual(1, arguments.foo.a)
     self.assertEqual(2, arguments.foo.b)
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:test_schema.py

示例14: test_default_list

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_default_list(self):
     """
     The default of a L{List} can be specified as a list.
     """
     schema = Schema(List("names", Unicode(), optional=True,
                          default=[u"foo", u"bar"]))
     arguments, _ = schema.extract({})
     self.assertEqual([u"foo", u"bar"], arguments.names)
开发者ID:antisvin,项目名称:txAWS,代码行数:10,代码来源:test_schema.py

示例15: test_add_extra_schema_items

# 需要导入模块: from txaws.server.schema import Schema [as 别名]
# 或者: from txaws.server.schema.Schema import extract [as 别名]
 def test_add_extra_schema_items(self):
     """A list of new Parameters can be added to the Schema."""
     schema = Schema(Unicode("name"))
     schema = schema.extend(Unicode("computer"), Integer("count"))
     arguments, _ = schema.extract({"name": "value", "computer": "testing",
                                    "count": "5"})
     self.assertEqual(u"value", arguments.name)
     self.assertEqual("testing", arguments.computer)
     self.assertEqual(5, arguments.count)
开发者ID:antisvin,项目名称:txAWS,代码行数:11,代码来源:test_schema.py


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