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


Python Name.wireDecode方法代码示例

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


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

示例1: getKeysOfIdentity

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import wireDecode [as 别名]
    def getKeysOfIdentity(self, identityName):
        """
        Get all the key names of the identity with the name identityName. The
        returned key names can be used to create a KeyContainer. With a key name
        and a backend implementation, one can create a Key front end instance.

        :param Name identityName: The name of the identity.
        :return: The set of key names. The Name objects are fresh copies. If the
          identity does not exist, return an empty set.
        :rtype: set of Name
        """
        keyNames = set()

        try:
            cursor = self._database.cursor()
            cursor.execute(
              "SELECT key_name " +
              "FROM keys JOIN identities ON keys.identity_id=identities.id " +
              "WHERE identities.identity=?",
              (sqlite3.Binary(bytearray(identityName.wireEncode().buf())), ))
            rows = cursor.fetchall()
            for (encoding, ) in rows:
                name = Name()
                name.wireDecode(bytearray(encoding))
                keyNames.add(name)
            cursor.close()
        except Exception as ex:
            raise PibImpl.Error("PibSqlite3: SQLite error: " + str(ex))

        return keyNames
开发者ID:named-data,项目名称:PyNDN2,代码行数:32,代码来源:pib_sqlite3.py

示例2: getCertificatesOfKey

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import wireDecode [as 别名]
    def getCertificatesOfKey(self, keyName):
        """
        Get a list of certificate names of the key with id keyName. The returned
        certificate names can be used to create a PibCertificateContainer. With a
        certificate name and a backend implementation, one can obtain the
        certificate.

        :param Name keyName: The name of the key.
        :return: The set of certificate names. The Name objects are fresh
          copies. If the key does not exist, return an empty set.
        :rtype: set of Name
        """
        certNames = set()

        try:
            cursor = self._database.cursor()
            cursor.execute(
              "SELECT certificate_name " +
              "FROM certificates JOIN keys ON certificates.key_id=keys.id " +
              "WHERE keys.key_name=?",
              (sqlite3.Binary(bytearray(keyName.wireEncode().buf())), ))
            rows = cursor.fetchall()
            for (encoding, ) in rows:
                name = Name()
                name.wireDecode(bytearray(encoding))
                certNames.add(name)
            cursor.close()
        except Exception as ex:
            raise PibImpl.Error("PibSqlite3: SQLite error: " + str(ex))

        return certNames
开发者ID:named-data,项目名称:PyNDN2,代码行数:33,代码来源:pib_sqlite3.py

示例3: getDefaultIdentity

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import wireDecode [as 别名]
    def getDefaultIdentity(self):
        """
        Get the default identity.

        :return: The name of the default identity, as a fresh copy.
        :rtype: Name
        :raises Pib.Error: For no default identity.
        """
        encoding = None
        try:
            cursor = self._database.cursor()
            cursor.execute("SELECT identity FROM identities WHERE is_default=1")
            row = cursor.fetchone()

            if row != None:
                (encoding,) = row
            cursor.close()
        except Exception as ex:
            raise PibImpl.Error("PibSqlite3: SQLite error: " + str(ex))

        if encoding != None:
            name = Name()
            name.wireDecode(bytearray(encoding))
            return name
        else:
            raise Pib.Error("No default identity")
开发者ID:named-data,项目名称:PyNDN2,代码行数:28,代码来源:pib_sqlite3.py

示例4: getScheduleMembers

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import wireDecode [as 别名]
    def getScheduleMembers(self, name):
        """
        For each member using the given schedule, get the name and public key
        DER of the member's key.

        :param str name: The name of the schedule.
        :return: a new dictionary where the dictionary's key is the Name of the
          public key and the value is the Blob of the public key DER. Note that
          the member's identity name is keyName.getPrefix(-1). If the schedule
          name is not found, the dictionary is empty.
        :rtype: dictionary<Name, Blob>
        :raises GroupManagerDb.Error: For a database error.
        """
        dictionary = {}

        try:
            cursor = self._database.cursor()
            cursor.execute(
                "SELECT key_name, pubkey "
                + "FROM members JOIN schedules ON members.schedule_id=schedules.schedule_id "
                + "WHERE schedule_name=?",
                (name,),
            )
            results = cursor.fetchall()
            for (keyNameEncoding, keyEncoding) in results:
                keyName = Name()
                keyName.wireDecode(bytearray(keyNameEncoding), TlvWireFormat.get())
                dictionary[keyName] = Blob(bytearray(keyEncoding), False)
            cursor.close()

            return dictionary
        except Exception as ex:
            raise GroupManagerDb.Error("Sqlite3GroupManagerDb.getScheduleMembers: SQLite error: " + str(ex))
开发者ID:named-data,项目名称:PyNDN2,代码行数:35,代码来源:sqlite3_group_manager_db.py

示例5: getIdentities

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import wireDecode [as 别名]
    def getIdentities(self):
        """
        Get the names of all the identities.

        :return: The a fresh set of identity names. The Name objects are fresh
          copies.
        :rtype: set of Name
        """
        identities = set()

        try:
            cursor = self._database.cursor()
            cursor.execute("SELECT identity FROM identities")
            rows = cursor.fetchall()
            for (encoding, ) in rows:
                name = Name()
                name.wireDecode(bytearray(encoding))
                identities.add(name)
            cursor.close()
        except Exception as ex:
            raise PibImpl.Error("PibSqlite3: SQLite error: " + str(ex))

        return identities
开发者ID:named-data,项目名称:PyNDN2,代码行数:25,代码来源:pib_sqlite3.py

示例6: listAllMembers

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import wireDecode [as 别名]
    def listAllMembers(self):
        """
        List all the members.

        :return: A new List of Name with the names of all members.
        :rtype: Array<Name>
        :raises GroupManagerDb.Error: For a database error.
        """
        list = []

        try:
            cursor = self._database.cursor()
            cursor.execute("SELECT member_name FROM members", ())
            results = cursor.fetchall()
            for (nameEncoding,) in results:
                identity = Name()
                identity.wireDecode(bytearray(nameEncoding), TlvWireFormat.get())
                list.append(identity)
            cursor.close()

            return list
        except Exception as ex:
            raise GroupManagerDb.Error("Sqlite3GroupManagerDb.listAllMembers: SQLite error: " + str(ex))
开发者ID:named-data,项目名称:PyNDN2,代码行数:25,代码来源:sqlite3_group_manager_db.py

示例7: getDefaultKeyOfIdentity

# 需要导入模块: from pyndn.name import Name [as 别名]
# 或者: from pyndn.name.Name import wireDecode [as 别名]
    def getDefaultKeyOfIdentity(self, identityName):
        """
        Get the name of the default key for the identity with name identityName.

        :param Name identityName: The name of the identity.
        :return: The name of the default key, as a fresh copy.
        :rtype: Name
        :raises Pib.Error: If there is no default key or if the identity does
          not exist.
        """
        if not self.hasIdentity(identityName):
            raise Pib.Error(
              "Identity `" + identityName.toUri() + "` does not exist")

        encoding = None
        try:
            cursor = self._database.cursor()
            cursor.execute(
              "SELECT key_name " +
              "FROM keys JOIN identities ON keys.identity_id=identities.id " +
              "WHERE identities.identity=? AND keys.is_default=1",
              (sqlite3.Binary(bytearray(identityName.wireEncode().buf())), ))
            row = cursor.fetchone()

            if row != None:
                (encoding,) = row
            cursor.close()
        except Exception as ex:
            raise PibImpl.Error("PibSqlite3: SQLite error: " + str(ex))

        if encoding != None:
            name = Name()
            name.wireDecode(bytearray(encoding))
            return name
        else:
            raise Pib.Error(
              "No default key for identity `" + identityName.toUri() + "`")
开发者ID:named-data,项目名称:PyNDN2,代码行数:39,代码来源:pib_sqlite3.py


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