src/eric7/EricNetwork/EricNetworkUtilities.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9653
e67609152c5e
equal deleted inserted replaced
9220:e9e7eca7efee 9221:bf71ee032bb4
11 11
12 12
13 def isValidAddress(address): 13 def isValidAddress(address):
14 """ 14 """
15 Public function to check, if the given address is valid. 15 Public function to check, if the given address is valid.
16 16
17 @param address IPv4 or IPv6 address string 17 @param address IPv4 or IPv6 address string
18 @type str 18 @type str
19 @return flag indicating validity 19 @return flag indicating validity
20 @rtype bool 20 @rtype bool
21 """ 21 """
24 24
25 25
26 def isValidIPv4Address(address): 26 def isValidIPv4Address(address):
27 """ 27 """
28 Public function to check, if the given address is a valid IPv4 address. 28 Public function to check, if the given address is a valid IPv4 address.
29 29
30 @param address IPv4 address string 30 @param address IPv4 address string
31 @type str 31 @type str
32 @return flag indicating validity 32 @return flag indicating validity
33 @rtype bool 33 @rtype bool
34 """ 34 """
35 h = QHostAddress(address) 35 h = QHostAddress(address)
36 return ( 36 return (
37 not h.isNull() and 37 not h.isNull()
38 h.protocol() == QAbstractSocket.NetworkLayerProtocol.IPv4Protocol 38 and h.protocol() == QAbstractSocket.NetworkLayerProtocol.IPv4Protocol
39 ) 39 )
40 40
41 41
42 def isValidIPv6Address(address): 42 def isValidIPv6Address(address):
43 """ 43 """
44 Public function to check, if the given address is a valid IPv6 address. 44 Public function to check, if the given address is a valid IPv6 address.
45 45
46 @param address IPv6 address string 46 @param address IPv6 address string
47 @type str 47 @type str
48 @return flag indicating validity 48 @return flag indicating validity
49 @rtype bool 49 @rtype bool
50 """ 50 """
51 h = QHostAddress(address) 51 h = QHostAddress(address)
52 return ( 52 return (
53 not h.isNull() and 53 not h.isNull()
54 h.protocol() == QAbstractSocket.NetworkLayerProtocol.IPv6Protocol 54 and h.protocol() == QAbstractSocket.NetworkLayerProtocol.IPv6Protocol
55 ) 55 )

eric ide

mercurial