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


Python Payload.add_field方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def __init__(self, sources, address=None, exports=None, **kwargs):
   payload = Payload()
   payload.add_field('sources', self.create_sources_field(sources,
                                                          sources_rel_path=address.spec_path,
                                                          key_arg='sources'))
   payload.add_field('exports', PrimitivesSetField(exports or []))
   super(SourcesTarget, self).__init__(address=address, payload=payload, **kwargs)
开发者ID:foursquare,项目名称:pants,代码行数:9,代码来源:test_target.py

示例2: test_partial_fingerprint

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def test_partial_fingerprint(self):
   payload = Payload()
   payload.add_field('foo', PrimitiveField())
   fingerprint1 = payload.fingerprint()
   self.assertEqual(fingerprint1, payload.fingerprint(field_keys=('foo',)))
   payload.add_field('bar', PrimitiveField())
   fingerprint2 = payload.fingerprint()
   self.assertEqual(fingerprint1, payload.fingerprint(field_keys=('foo',)))
   self.assertNotEqual(fingerprint2, payload.fingerprint(field_keys=('foo',)))
   self.assertNotEqual(fingerprint2, payload.fingerprint(field_keys=('bar',)))
   self.assertEqual(fingerprint2, payload.fingerprint(field_keys=('bar', 'foo')))
开发者ID:pcurry,项目名称:pants,代码行数:13,代码来源:test_payload.py

示例3: test_fingerprint

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def test_fingerprint(self):
   payload = Payload()
   payload.add_field('foo', PrimitiveField())
   fingerprint1 = payload.fingerprint()
   self.assertEqual(fingerprint1, payload.fingerprint())
   payload.add_field('bar', PrimitiveField())
   fingerprint2 = payload.fingerprint()
   self.assertNotEqual(fingerprint1, fingerprint2)
   self.assertEqual(fingerprint2, payload.fingerprint())
   payload.freeze()
   self.assertEqual(fingerprint2, payload.fingerprint())
开发者ID:pcurry,项目名称:pants,代码行数:13,代码来源:test_payload.py

示例4: test_partial_fingerprint

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def test_partial_fingerprint(self):
     payload = Payload()
     payload.add_field("foo", PrimitiveField())
     fingerprint1 = payload.fingerprint()
     self.assertEqual(fingerprint1, payload.fingerprint(field_keys=("foo",)))
     payload.add_field("bar", PrimitiveField())
     fingerprint2 = payload.fingerprint()
     self.assertEqual(fingerprint1, payload.fingerprint(field_keys=("foo",)))
     self.assertNotEqual(fingerprint2, payload.fingerprint(field_keys=("foo",)))
     self.assertNotEqual(fingerprint2, payload.fingerprint(field_keys=("bar",)))
     self.assertEqual(fingerprint2, payload.fingerprint(field_keys=("bar", "foo")))
开发者ID:jduan,项目名称:pants,代码行数:13,代码来源:test_payload.py

示例5: payload_for_scope

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def payload_for_scope(self, scope):
   """Returns a payload representing the options for the given scope."""
   payload = Payload()
   for (name, _, kwargs) in self.registration_args_iter_for_scope(scope):
     if not kwargs.get('fingerprint', False):
       continue
     val = self.for_scope(scope)[name]
     val_type = kwargs.get('type', '')
     if val_type == Options.file:
       field = FileField(val)
     elif val_type == Options.target_list:
       field = TargetListField(val)
     else:
       field = PrimitiveField(val)
     payload.add_field(name, field)
   payload.freeze()
   return payload
开发者ID:digwanderlust,项目名称:pants,代码行数:19,代码来源:options.py

示例6: test_missing_payload_field

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def test_missing_payload_field(self):
   payload = Payload()
   payload.add_field('foo', PrimitiveField('test-value'))
   payload.add_field('bar', PrimitiveField(None))
   self.assertEquals('test-value', payload.foo);
   self.assertEquals('test-value', payload.get_field('foo').value)
   self.assertEquals('test-value', payload.get_field_value('foo'))
   self.assertEquals(None, payload.bar);
   self.assertEquals(None, payload.get_field('bar').value)
   self.assertEquals(None, payload.get_field_value('bar'))
   self.assertEquals(None, payload.get_field('bar', default='nothing').value)
   self.assertEquals(None, payload.get_field_value('bar', default='nothing'))
   with self.assertRaises(KeyError):
     self.assertEquals(None, payload.field_doesnt_exist)
   self.assertEquals(None, payload.get_field('field_doesnt_exist'))
   self.assertEquals(None, payload.get_field_value('field_doesnt_exist'))
   self.assertEquals('nothing', payload.get_field('field_doesnt_exist', default='nothing'))
   self.assertEquals('nothing', payload.get_field_value('field_doesnt_exist', default='nothing'))
开发者ID:pcurry,项目名称:pants,代码行数:20,代码来源:test_payload.py

示例7: test_missing_payload_field

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def test_missing_payload_field(self):
     payload = Payload()
     payload.add_field("foo", PrimitiveField("test-value"))
     payload.add_field("bar", PrimitiveField(None))
     self.assertEquals("test-value", payload.foo)
     self.assertEquals("test-value", payload.get_field("foo").value)
     self.assertEquals("test-value", payload.get_field_value("foo"))
     self.assertEquals(None, payload.bar)
     self.assertEquals(None, payload.get_field("bar").value)
     self.assertEquals(None, payload.get_field_value("bar"))
     self.assertEquals(None, payload.get_field("bar", default="nothing").value)
     self.assertEquals(None, payload.get_field_value("bar", default="nothing"))
     with self.assertRaises(KeyError):
         self.assertEquals(None, payload.field_doesnt_exist)
     self.assertEquals(None, payload.get_field("field_doesnt_exist"))
     self.assertEquals(None, payload.get_field_value("field_doesnt_exist"))
     self.assertEquals("nothing", payload.get_field("field_doesnt_exist", default="nothing"))
     self.assertEquals("nothing", payload.get_field_value("field_doesnt_exist", default="nothing"))
开发者ID:jduan,项目名称:pants,代码行数:20,代码来源:test_payload.py

示例8: __init__

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def __init__(self, contents, **kwargs):
   payload = Payload()
   payload.add_field('contents', PrimitiveField(contents))
   super(MinimalImplResourcesTaskTest.TestTarget, self).__init__(payload=payload, **kwargs)
开发者ID:priyakoth,项目名称:pants,代码行数:6,代码来源:test_resources_task.py

示例9: test_none

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def test_none(self):
   payload = Payload()
   payload.add_field('foo', None)
   payload2 = Payload()
   payload2.add_field('foo', PrimitiveField(None))
   self.assertNotEqual(payload.fingerprint(), payload2.fingerprint())
开发者ID:pcurry,项目名称:pants,代码行数:8,代码来源:test_payload.py

示例10: test_field_duplication

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def test_field_duplication(self):
   payload = Payload()
   payload.add_field('foo', PrimitiveField())
   payload.freeze()
   with self.assertRaises(PayloadFieldAlreadyDefinedError):
     payload.add_field('foo', PrimitiveField())
开发者ID:pcurry,项目名称:pants,代码行数:8,代码来源:test_payload.py

示例11: test_freeze

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def test_freeze(self):
   payload = Payload()
   payload.add_field('foo', PrimitiveField())
   payload.freeze()
   with self.assertRaises(PayloadFrozenError):
     payload.add_field('bar', PrimitiveField())
开发者ID:pcurry,项目名称:pants,代码行数:8,代码来源:test_payload.py

示例12: _make_payload_from_sources

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def _make_payload_from_sources(self, sources):
   p = Payload()
   p.add_field('sources', SourcesField('', sources))
   p.freeze()
   return p
开发者ID:Gabriel439,项目名称:pants,代码行数:7,代码来源:test_jvm_dependency_usage.py

示例13: __init__

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import add_field [as 别名]
 def __init__(me, sources, address=None, **kwargs):
   payload = Payload()
   payload.add_field('sources', me.create_sources_field(sources,
                                                        sources_rel_path=address.spec_path,
                                                        key_arg='sources'))
   super(SourcesTarget, me).__init__(address=address, payload=payload, **kwargs)
开发者ID:grimreaper,项目名称:pants,代码行数:8,代码来源:test_target.py


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