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


Python Payload.fingerprint方法代码示例

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


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

示例1: test_fingerprint

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import fingerprint [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

示例2: ManifestEntries

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import fingerprint [as 别名]
class ManifestEntries(FingerprintedMixin):
  """Describes additional items to add to the app manifest."""

  class ExpectedDictionaryError(Exception):
    pass

  def __init__(self, entries=None):
    """
    :param entries: Additional headers, value pairs to add to the MANIFEST.MF.
      You can just add fixed string header / value pairs.
    :type entries: dictionary of string : string
    """
    self.payload = Payload()
    if entries:
      if not isinstance(entries, dict):
        raise self.ExpectedDictionaryError("entries must be a dictionary of strings.")
      for key in entries.keys():
        if not isinstance(key, string_types):
          raise self.ExpectedDictionaryError(
            "entries must be dictionary of strings, got key {} type {}"
            .format(key, type(key).__name__))
    self.payload.add_fields({
      'entries' : PrimitiveField(entries or {}),
      })

  def fingerprint(self):
    return self.payload.fingerprint()

  @property
  def entries(self):
    return self.payload.entries
开发者ID:MathewJennings,项目名称:pants,代码行数:33,代码来源:jvm_binary.py

示例3: test_partial_fingerprint

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import fingerprint [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

示例4: test_partial_fingerprint

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import fingerprint [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: test_none

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import fingerprint [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

示例6: JarRules

# 需要导入模块: from pants.base.payload import Payload [as 别名]
# 或者: from pants.base.payload.Payload import fingerprint [as 别名]
class JarRules(FingerprintedMixin):
  """A set of rules for packaging up a deploy jar.

  Deploy jars are executable jars with fully self-contained classpaths and as such, assembling them
  presents problems given jar semantics.

  One issue is signed jars that must be included on the
  classpath.  These have a signature that depends on the jar contents and assembly of the deploy jar
  changes the content of the jar, breaking the signatures.  For cases like these the signed jars
  must be verified and then the signature information thrown away.  The `Skip <#Skip>`_
  rule supports this sort of issue by allowing outright entry exclusion in the final deploy jar.

  Another issue is duplicate jar entries.  Although the underlying zip format supports these, the
  java jar tool and libraries do not.  As such some action must be taken for each duplicate entry
  such that there are no duplicates in the final deploy jar.  The four
  `Duplicate <#Duplicate>`_ rules support resolution of these cases by allowing 1st wins,
  last wins, concatenation of the duplicate entry contents or raising an exception.
  """
  @classmethod
  def skip_signatures_and_duplicates_concat_well_known_metadata(cls, default_dup_action=None,
                                                                additional_rules=None):
    """Produces a rule set useful in many deploy jar creation contexts.

    The rule set skips duplicate entries by default, retaining the 1st encountered.  In addition it
    has the following special handling:

    - jar signature metadata is dropped
    - ``java.util.ServiceLoader`` provider-configuration files are concatenated in the order
      encountered

    :param default_dup_action: An optional default action to take for duplicates.  Defaults to
      `Duplicate.SKIP` if not specified.
    :param additional_rules: Optionally one or more jar rules to add to those described above.
    :returns: JarRules
    """
    default_dup_action = Duplicate.validate_action(default_dup_action or Duplicate.SKIP)
    additional_rules = assert_list(additional_rules, expected_type=(Duplicate, Skip))

    rules = [Skip(r'^META-INF/[^/]+\.SF$'),  # signature file
             Skip(r'^META-INF/[^/]+\.DSA$'),  # default signature alg. file
             Skip(r'^META-INF/[^/]+\.RSA$'),  # default signature alg. file
             Duplicate(r'^META-INF/services/', Duplicate.CONCAT)]  # 1 svc fqcn per line

    return JarRules(rules=rules + additional_rules, default_dup_action=default_dup_action)

  _DEFAULT = None

  @classmethod
  def default(cls):
    """Returns the default set of jar rules.

    Can be set with `set_default` but otherwise defaults to
    `skip_signatures_and_duplicates_concat_well_known_metadata`.
    """
    if cls._DEFAULT is None:
      cls._DEFAULT = cls.skip_signatures_and_duplicates_concat_well_known_metadata()
    return cls._DEFAULT

  @classmethod
  def set_default(cls, rules):
    """Sets the default site-wide jar rules."""
    if not isinstance(rules, JarRules):
      raise ValueError('The default rules must be a JarRules instance.')
    cls._DEFAULT = rules

  def __init__(self, rules=None, default_dup_action=Duplicate.SKIP):
    """Creates a new set of jar rules with the default duplicate action of ``Duplicate.SKIP``.

    :param rules: One or more rules that will be applied in order to jar entries being packaged in
      a deploy jar. `Skip <#Skip>`_ rules can go here.
    :param default_dup_action: The default action to take when a duplicate entry is encountered and
      no explicit rules apply to the entry.
    """
    self.payload = Payload()
    self.payload.add_fields({
      'default_dup_action' : PrimitiveField(Duplicate.validate_action(default_dup_action))
    })
    self._rules = assert_list(rules, expected_type=JarRule)

  @property
  def default_dup_action(self):
    """The default action to take when a duplicate jar entry is encountered."""
    return self.payload.default_dup_action

  @property
  def rules(self):
    """A copy of the list of explicit entry rules in effect."""
    return list(self._rules)

  def fingerprint(self):
    hasher = sha1()
    hasher.update(self.payload.fingerprint())
    for rule in self.rules:
      hasher.update(rule.fingerprint())
    return hasher.hexdigest()

  @property
  def value(self):
    return self._jar_rules
开发者ID:MathewJennings,项目名称:pants,代码行数:101,代码来源:jvm_binary.py


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