當前位置: 首頁>>代碼示例>>Python>>正文


Python Network.to_compressed方法代碼示例

本文整理匯總了Python中ipcalc.Network.to_compressed方法的典型用法代碼示例。如果您正苦於以下問題:Python Network.to_compressed方法的具體用法?Python Network.to_compressed怎麽用?Python Network.to_compressed使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ipcalc.Network的用法示例。


在下文中一共展示了Network.to_compressed方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_ipv6_4

# 需要導入模塊: from ipcalc import Network [as 別名]
# 或者: from ipcalc.Network import to_compressed [as 別名]
 def test_ipv6_4(self):
     net = Network('2001:dead:beef:1:c01d:c01a::', 'ffff:ffff:ffff::')
     self.assertTrue(str(net) == '2001:dead:beef:0001:c01d:c01a:0000:0000/48')
     self.assertTrue(str(net.to_compressed()) == '2001:dead:beef:1:c01d:c01a::')
     self.assertTrue(str(net.to_ipv6().to_compressed()) == '2001:dead:beef:1:c01d:c01a::')
     self.assertTrue(net.info() == 'UNKNOWN')
     self.assertTrue(net.subnet() == 48)
     self.assertTrue(net.size() == 1 << (128 - 48))
     self.assertTrue(int(net) == 0x2001deadbeef0001c01dc01a00000000)
     self.assertTrue(net.hex().lower() == '2001deadbeef0001c01dc01a00000000')
     self.assertTrue(str(net.netmask()) == 'ffff:ffff:ffff:0000:0000:0000:0000:0000')
     self.assertTrue(net.version() == 6)
     self.assertTrue(str(net.network()) == '2001:dead:beef:0000:0000:0000:0000:0000')
     self.assertTrue(str(net.broadcast()) == '2001:dead:beef:ffff:ffff:ffff:ffff:ffff')
     self.assertFalse('123:456::' in net)
     self.assertFalse('::aaaa:bbbb:cccc:dddd' in net)
     self.assertFalse('::dddd' in net)
     self.assertFalse('::1' in net)
     self.assertFalse('123::456' in net)
     self.assertTrue('2001:dead:beef:babe::1234' in net)
開發者ID:panaceya,項目名稱:ipcalc,代碼行數:22,代碼來源:test.py

示例2: test_ipv6_4

# 需要導入模塊: from ipcalc import Network [as 別名]
# 或者: from ipcalc.Network import to_compressed [as 別名]
 def test_ipv6_4(self):
     net = Network("2001:dead:beef:1:c01d:c01a::", "ffff:ffff:ffff::")
     self.assertTrue(str(net) == "2001:dead:beef:0001:c01d:c01a:0000:0000/48")
     self.assertTrue(str(net.to_compressed()) == "2001:dead:beef:1:c01d:c01a::")
     self.assertTrue(str(net.to_ipv6().to_compressed()) == "2001:dead:beef:1:c01d:c01a::")
     self.assertTrue(net.info() == "UNKNOWN")
     self.assertTrue(net.subnet() == 48)
     self.assertTrue(net.size() == 1 << (128 - 48))
     self.assertTrue(int(net) == 0x2001DEADBEEF0001C01DC01A00000000)
     self.assertTrue(net.hex().lower() == "2001deadbeef0001c01dc01a00000000")
     self.assertTrue(str(net.netmask()) == "ffff:ffff:ffff:0000:0000:0000:0000:0000")
     self.assertTrue(net.version() == 6)
     self.assertTrue(str(net.network()) == "2001:dead:beef:0000:0000:0000:0000:0000")
     self.assertTrue(str(net.broadcast()) == "2001:dead:beef:ffff:ffff:ffff:ffff:ffff")
     self.assertFalse("123:456::" in net)
     self.assertFalse("::aaaa:bbbb:cccc:dddd" in net)
     self.assertFalse("::dddd" in net)
     self.assertFalse("::1" in net)
     self.assertFalse("123::456" in net)
     self.assertTrue("2001:dead:beef:babe::1234" in net)
開發者ID:osilva,項目名稱:ipcalc,代碼行數:22,代碼來源:test.py

示例3: test_ipv6_1

# 需要導入模塊: from ipcalc import Network [as 別名]
# 或者: from ipcalc.Network import to_compressed [as 別名]
 def test_ipv6_1(self):
     net = Network('123::', 128)
     self.assertTrue(str(net) == '0123:0000:0000:0000:0000:0000:0000:0000/128')
     self.assertTrue(str(net.to_compressed()) == '123::')
     self.assertTrue(str(net.to_ipv6().to_compressed()) == '123::')
     self.assertTrue(net.info() == 'UNKNOWN')
     self.assertTrue(net.subnet() == 128)
     self.assertTrue(net.size() == 1 << (128 - 128))
     self.assertTrue(int(net) == (0x123<<112))
     self.assertTrue(net.hex().lower() == '01230000000000000000000000000000')
     self.assertTrue(str(net.netmask()) == 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff')
     self.assertTrue(net.version() == 6)
     self.assertTrue(str(net.network()) == '0123:0000:0000:0000:0000:0000:0000:0000')
     self.assertTrue(str(net.broadcast()) == '0123:0000:0000:0000:0000:0000:0000:0000')
     self.assertFalse('123:456::' in net)
     self.assertTrue('123::' in net)
     self.assertFalse('::1' in net)
     self.assertFalse('123::456' in net)
     self.assertTrue(str((net + 6).to_compressed()).lower() == '123::6')
     self.assertFalse((net + 6) in net)
     self.assertTrue(str((net - 6).to_compressed()).lower() == '122:ffff:ffff:ffff:ffff:ffff:ffff:fffa')
     self.assertFalse((net - 6) in net)
開發者ID:panaceya,項目名稱:ipcalc,代碼行數:24,代碼來源:test.py

示例4: test_ipv6_1

# 需要導入模塊: from ipcalc import Network [as 別名]
# 或者: from ipcalc.Network import to_compressed [as 別名]
 def test_ipv6_1(self):
     net = Network("123::", 128)
     self.assertTrue(str(net) == "0123:0000:0000:0000:0000:0000:0000:0000/128")
     self.assertTrue(str(net.to_compressed()) == "123::")
     self.assertTrue(str(net.to_ipv6().to_compressed()) == "123::")
     self.assertTrue(net.info() == "UNKNOWN")
     self.assertTrue(net.subnet() == 128)
     self.assertTrue(net.size() == 1 << (128 - 128))
     self.assertTrue(int(net) == (0x123 << 112))
     self.assertTrue(net.hex().lower() == "01230000000000000000000000000000")
     self.assertTrue(str(net.netmask()) == "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff")
     self.assertTrue(net.version() == 6)
     self.assertTrue(str(net.network()) == "0123:0000:0000:0000:0000:0000:0000:0000")
     self.assertTrue(str(net.broadcast()) == "0123:0000:0000:0000:0000:0000:0000:0000")
     self.assertFalse("123:456::" in net)
     self.assertTrue("123::" in net)
     self.assertFalse("::1" in net)
     self.assertFalse("123::456" in net)
     self.assertTrue(str((net + 6).to_compressed()).lower() == "123::6")
     self.assertFalse((net + 6) in net)
     self.assertTrue(str((net - 6).to_compressed()).lower() == "122:ffff:ffff:ffff:ffff:ffff:ffff:fffa")
     self.assertFalse((net - 6) in net)
開發者ID:osilva,項目名稱:ipcalc,代碼行數:24,代碼來源:test.py

示例5: test_ipv6_2

# 需要導入模塊: from ipcalc import Network [as 別名]
# 或者: from ipcalc.Network import to_compressed [as 別名]
 def test_ipv6_2(self):
     net = Network('::42', 64)
     self.assertTrue(str(net) == '0000:0000:0000:0000:0000:0000:0000:0042/64')
     self.assertTrue(str(net.to_compressed()) == '::42')
     self.assertTrue(str(net.to_ipv6().to_compressed()) == '::42')
     self.assertTrue(net.info() == 'IPV4COMP')
     self.assertTrue(net.subnet() == 64)
     self.assertTrue(net.size() == 1 << (128 - 64))
     self.assertTrue(int(net) == 0x42)
     self.assertTrue(net.hex().lower() == '00000000000000000000000000000042')
     self.assertTrue(str(net.netmask()) == 'ffff:ffff:ffff:ffff:0000:0000:0000:0000')
     self.assertTrue(net.version() == 6)
     self.assertTrue(str(net.network()) == '0000:0000:0000:0000:0000:0000:0000:0000')
     self.assertTrue(str(net.broadcast()) == '0000:0000:0000:0000:ffff:ffff:ffff:ffff')
     self.assertFalse('123:456::' in net)
     self.assertTrue('::aaaa:bbbb:cccc:dddd' in net)
     self.assertTrue('::dddd' in net)
     self.assertTrue('::1' in net)
     self.assertFalse('123::456' in net)
     self.assertTrue(str((net + 6).to_compressed()).lower() == '::48')
     self.assertTrue((net + 6) in net)
     self.assertTrue(str((net - 6).to_compressed()).lower() == '::3c')
     self.assertTrue((net - 6) in net)
開發者ID:panaceya,項目名稱:ipcalc,代碼行數:25,代碼來源:test.py


注:本文中的ipcalc.Network.to_compressed方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。