message.py 文件源码

python
阅读 52 收藏 0 点赞 0 评论 0

项目:sprockets 作者: google 项目源码 文件源码
def Match(self, encoded):
    """Whether or not |encoded| is compatible with this message instance.

    If |encoded| has all required fields, and values of all fields are same to
    those of this message instance, it is compatible. Otherwise, i.e
    1) it doesn't have some required fields
    2) it has some values of fields different from specified in |value_dict| of
       this message instance

    Args:
      encoded: A string expected to be encoded with same encoding method of
          this message instance.

    Returns:
      Whether or not |encoded| is compatible with this message instance.
    """
    logging.log(1, 'Decoding %s: %s', self.name, encoded)
    decoded = self.msg.encoding.ParseFromString(encoded, self.msg)
    logging.info('Matching message value:\nExpected: %s\nActual: %s\n',
                 self.value_dict_or_array, decoded)
    return MessageValue._MatchValue(self.value_dict_or_array, decoded)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号