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


Python KnownHostsFile.iterentries方法代码示例

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


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

示例1: test_defaultInitializerIgnoresExisting

# 需要导入模块: from twisted.conch.client.knownhosts import KnownHostsFile [as 别名]
# 或者: from twisted.conch.client.knownhosts.KnownHostsFile import iterentries [as 别名]
 def test_defaultInitializerIgnoresExisting(self):
     """
     The default initializer for L{KnownHostsFile} disregards any existing
     contents in the save path.
     """
     hostsFile = KnownHostsFile(self.pathWithContent(sampleHashedLine))
     self.assertEqual([], list(hostsFile.iterentries()))
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:9,代码来源:test_knownhosts.py

示例2: test_iterentriesUnsaved

# 需要导入模块: from twisted.conch.client.knownhosts import KnownHostsFile [as 别名]
# 或者: from twisted.conch.client.knownhosts.KnownHostsFile import iterentries [as 别名]
 def test_iterentriesUnsaved(self):
     """
     If the save path for a L{KnownHostsFile} does not exist,
     L{KnownHostsFile.iterentries} still returns added but unsaved entries.
     """
     hostsFile = KnownHostsFile(FilePath(self.mktemp()))
     hostsFile.addHostKey("www.example.com", Key.fromString(sampleKey))
     self.assertEqual(1, len(list(hostsFile.iterentries())))
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:10,代码来源:test_knownhosts.py

示例3: test_savingAvoidsDuplication

# 需要导入模块: from twisted.conch.client.knownhosts import KnownHostsFile [as 别名]
# 或者: from twisted.conch.client.knownhosts.KnownHostsFile import iterentries [as 别名]
    def test_savingAvoidsDuplication(self):
        """
        L{KnownHostsFile.save} only writes new entries to the save path, not
        entries which were added and already written by a previous call to
        C{save}.
        """
        path = FilePath(self.mktemp())
        knownHosts = KnownHostsFile(path)
        entry = knownHosts.addHostKey(
            "some.example.com", Key.fromString(sampleKey))
        knownHosts.save()
        knownHosts.save()

        knownHosts = KnownHostsFile.fromPath(path)
        self.assertEqual([entry], list(knownHosts.iterentries()))
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:17,代码来源:test_knownhosts.py

示例4: test_saveResetsClobberState

# 需要导入模块: from twisted.conch.client.knownhosts import KnownHostsFile [as 别名]
# 或者: from twisted.conch.client.knownhosts.KnownHostsFile import iterentries [as 别名]
    def test_saveResetsClobberState(self):
        """
        After L{KnownHostsFile.save} is used once with an instance initialized
        by the default initializer, contents of the save path are respected and
        preserved.
        """
        hostsFile = KnownHostsFile(self.pathWithContent(sampleHashedLine))
        preSave = hostsFile.addHostKey(
            "www.example.com", Key.fromString(otherSampleKey))
        hostsFile.save()
        postSave = hostsFile.addHostKey(
            "another.example.com", Key.fromString(thirdSampleKey))
        hostsFile.save()

        self.assertEqual([preSave, postSave], list(hostsFile.iterentries()))
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:17,代码来源:test_knownhosts.py

示例5: test_defaultInitializerClobbersExisting

# 需要导入模块: from twisted.conch.client.knownhosts import KnownHostsFile [as 别名]
# 或者: from twisted.conch.client.knownhosts.KnownHostsFile import iterentries [as 别名]
 def test_defaultInitializerClobbersExisting(self):
     """
     After using the default initializer for L{KnownHostsFile}, the first use
     of L{KnownHostsFile.save} overwrites any existing contents in the save
     path.
     """
     path = self.pathWithContent(sampleHashedLine)
     hostsFile = KnownHostsFile(path)
     entry = hostsFile.addHostKey(
         "www.example.com", Key.fromString(otherSampleKey))
     hostsFile.save()
     # Check KnownHostsFile to see what it thinks the state is
     self.assertEqual([entry], list(hostsFile.iterentries()))
     # And also directly check the underlying file itself
     self.assertEqual(entry.toString() + "\n", path.getContent())
开发者ID:12019,项目名称:OpenWrt_Luci_Lua,代码行数:17,代码来源:test_knownhosts.py


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