本文整理汇总了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)
示例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')))
示例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())
示例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")))
示例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
示例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'))
示例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"))
示例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)
示例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())
示例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())
示例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())
示例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
示例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)