MCPcopy Index your code
hub / github.com/qiyeboy/IPProxyPool / getIpAddr

Method getIpAddr

util/IPAddress.py:90–113  ·  view source on GitHub ↗
(self, ip)

Source from the content-addressed store, hash-verified

88 (self.curEndIp,) = struct.unpack("I", buf)
89
90 def getIpAddr(self, ip):
91 L = 0
92 R = self.indexCount - 1
93 while L < R - 1:
94 M = int((L + R) / 2)
95 self.setIpRange(M)
96 if ip == self.curStartIp:
97 L = M
98 break
99 if ip > self.curStartIp:
100 L = M
101 else:
102 R = M
103 self.setIpRange(L)
104 # version information, 255.255.255.X, urgy but useful
105 if ip & 0xffffff00 == 0xffffff00:
106 self.setIpRange(R)
107 if self.curStartIp <= ip <= self.curEndIp:
108 address = self.getAddr(self.curEndIpOffset)
109 # 把GBK转为utf-8
110 address = text_(address)
111 else:
112 address = text_("未找到该IP的地址")
113 return address
114
115 def getIpRange(self, ip):
116 self.getIpAddr(ip)

Callers 5

getVersionMethod · 0.95
getIpRangeMethod · 0.95
XpathPraserMethod · 0.45
RegularPraserMethod · 0.45
proxy_listPraserMethod · 0.45

Calls 3

setIpRangeMethod · 0.95
getAddrMethod · 0.95
text_Function · 0.90

Tested by

no test coverage detected