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


Python Name.size方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import size [as 别名]
    def __init__(self, prefix, dataType, face, keyChain, database, repeatAttempts=None, keyRetrievalLink=None):
        self._face = face
        self._keyChain = keyChain
        self._database = database
        self._maxRepeatAttempts = 3 if repeatAttempts == None else repeatAttempts
        self._keyRetrievalLink = Producer.NO_LINK if keyRetrievalLink == None else Link(keyRetrievalLink)

        # The dictionary key is the key Name The value is a Producer._KeyInfo.
        self._eKeyInfo = {}
        # The dictionary key is the float time stamp. The value is a Producer._KeyRequest.
        self._keyRequests = {}

        fixedPrefix = Name(prefix)
        fixedDataType = Name(dataType)

        # Fill _ekeyInfo with all permutations of dataType, including the 'E-KEY'
        # component of the name. This will be used in createContentKey to send
        # interests without reconstructing names every time.
        fixedPrefix.append(Encryptor.NAME_COMPONENT_READ)
        while fixedDataType.size() > 0:
            nodeName = Name(fixedPrefix)
            nodeName.append(fixedDataType)
            nodeName.append(Encryptor.NAME_COMPONENT_E_KEY)

            self._eKeyInfo[nodeName] = Producer._KeyInfo()
            fixedDataType = fixedDataType.getPrefix(-1)

        fixedPrefix.append(dataType)
        self._namespace = Name(prefix)
        self._namespace.append(Encryptor.NAME_COMPONENT_SAMPLE)
        self._namespace.append(dataType)
开发者ID:named-data,项目名称:PyNDN2,代码行数:33,代码来源:producer.py

示例2: signByIdentity

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import size [as 别名]
    def signByIdentity(self, target, identityName = None, wireFormat = None):
        """
        Sign the target. If it is a Data object, set its signature.
        If it is an array, return a signature object.

        :param target: If this is a Data object, wire encode for signing,
          update its signature and key locator field and wireEncoding. If it is
          an array, sign it and return a Signature object.
        :type target: Data or an array which implements the buffer protocol
        :param Name identityName: (optional) The identity name for the key to
          use for signing. If omitted, infer the signing identity from the data
          packet name.
        :param wireFormat: (optional) A WireFormat object used to encode the
           input. If omitted, use WireFormat.getDefaultWireFormat().
        :type wireFormat: A subclass of WireFormat
        :return: The Signature object (only if the target is an array).
        :rtype: An object of a subclass of Signature
        """
        if identityName == None:
            identityName = Name()


        if isinstance(target, Data):
            if identityName.size() == 0:
                inferredIdentity = self._policyManager.inferSigningIdentity(
                  target.getName())
                if inferredIdentity.size() == 0:
                    signingCertificateName = self._identityManager.getDefaultCertificateName()
                else:
                    signingCertificateName = \
                      self._identityManager.getDefaultCertificateNameForIdentity(inferredIdentity)
            else:
                signingCertificateName = \
                  self._identityManager.getDefaultCertificateNameForIdentity(identityName)

            if signingCertificateName.size() == 0:
                raise SecurityException("No qualified certificate name found!")

            if not self._policyManager.checkSigningPolicy(
                  target.getName(), signingCertificateName):
                raise SecurityException(
                  "Signing Cert name does not comply with signing policy")

            self._identityManager.signByCertificate(
              target, signingCertificateName, wireFormat)
        else:
            signingCertificateName = \
              self._identityManager.getDefaultCertificateNameForIdentity(identityName)

            if signingCertificateName.size() == 0:
                raise SecurityException("No qualified certificate name found!")

            return self._identityManager.signByCertificate(
              target, signingCertificateName)
开发者ID:WeiqiJust,项目名称:NDN-total,代码行数:56,代码来源:key_chain.py

示例3: ChronoSync2013

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import size [as 别名]

#.........这里部分代码省略.........
        def __init__(self, dataPrefixUri, sessionNo):
            self._dataPrefixUri = dataPrefixUri
            self._sessionNo = sessionNo

        def getDataPrefix(self):
            """
            Get the application data prefix.

            :return: The application data prefix as a Name URI string.
            :rtype: str
            """
            return self._dataPrefixUri

        def getSessionNo(self):
            """
            Get the session number associated with the application data prefix.

            :return: The session number.
            :rtype: int
            """
            return self._sessionNo

    def getProducerPrefixes(self):
        """
        Get a copy of the current list of producer data prefixes, and the
        associated session number. You can use these in getProducerSequenceNo().
        This includes the prefix for this user.

        :return: A copy of the list of each producer prefix and session number.
        :rtype: array of ChronoSync2013.PrefixAndSessionNo
        """
        prefixes = []

        for i in range(self._digestTree.size()):
            node = self._digestTree.get(i)
            prefixes.append(ChronoSync2013.PrefixAndSessionNo
              (node.getDataPrefix(), node.getSessionNo()))

        return prefixes

    def getProducerSequenceNo(self, dataPrefix, sessionNo):
        """
        Get the current sequence number in the digest tree for the given
        producer dataPrefix and sessionNo.

        :param std dataPrefix: The producer data prefix as a Name URI string.
        :param int sessionNo: The producer session number.
        :return: The current producer sequence number, or -1 if the producer
          namePrefix and sessionNo are not in the digest tree.
        :rtype: int
        """
        index = self._digestTree.find(dataPrefix, sessionNo)
        if index < 0:
          return -1
        else:
          return self._digestTree.get(index).getSequenceNo()

    def publishNextSequenceNo(self, applicationInfo = None):
        """
        Increment the sequence number, create a sync message with the new
        sequence number and publish a data packet where the name is
        the applicationBroadcastPrefix + the root digest of the current digest
        tree. Then add the sync message to the digest tree and digest log which
        creates a new root digest. Finally, express an interest for the next sync
        update with the name applicationBroadcastPrefix + the new root digest.
        After this, your application should publish the content for the new
开发者ID:named-data,项目名称:PyNDN2,代码行数:70,代码来源:chrono_sync2013.py

示例4: Data

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import size [as 别名]

#.........这里部分代码省略.........
        """
        return self._defaultWireEncodingFormat

    def getIncomingFaceId(self):
        """
        Get the incoming face ID according to the incoming packet header.

        :return: The incoming face ID. If not specified, return None.
        :rtype: int
        """
        field = (None if self._lpPacket == None
                 else IncomingFaceId.getFirstHeader(self._lpPacket))
        return None if field == None else field.getFaceId()

    def getFullName(self, wireFormat = None):
        """
        Get the Data packet's full name, which includes the final
        ImplicitSha256Digest component based on the wire encoding for a
        particular wire format.

        :param wireFormat: (optional) A WireFormat object used to encode
           this object. If omitted, use WireFormat.getDefaultWireFormat().
        :type wireFormat: A subclass of WireFormat
        :return: The full name. You must not change the Name object - if you
          need to change it then make a copy.
        :rtype: Name
        """
        if wireFormat == None:
            # Don't use a default argument since getDefaultWireFormat can change.
            wireFormat = WireFormat.getDefaultWireFormat()

        # The default full name depends on the default wire encoding.
        if (not self.getDefaultWireEncoding().isNull() and
            self._defaultFullName.size() > 0 and
            self.getDefaultWireEncodingFormat() == wireFormat):
            # We already have a full name. A non-null default wire encoding
            # means that the Data packet fields have not changed.
            return self._defaultFullName

        fullName = Name(self.getName())
        sha256 = hashes.Hash(hashes.SHA256(), backend=default_backend())
        sha256.update(self.wireEncode(wireFormat).toBytes())
        fullName.appendImplicitSha256Digest(
          Blob(bytearray(sha256.finalize()), False))

        if wireFormat == WireFormat.getDefaultWireFormat():
          # wireEncode has already set defaultWireEncodingFormat_.
          self._defaultFullName = fullName

        return fullName

    def setName(self, name):
        """
        Set name to a copy of the given Name.

        :param Name name: The Name which is copied.
        :return: This Data so that you can chain calls to update values.
        :rtype: Data
        """
        self._name.set(name if type(name) is Name else Name(name))
        self._changeCount += 1
        return self

    def setMetaInfo(self, metaInfo):
        """
        Set metaInfo to a copy of the given MetaInfo.
开发者ID:,项目名称:,代码行数:70,代码来源:


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