eric6/E5Network/__init__.py

Mon, 12 Oct 2020 18:23:44 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Mon, 12 Oct 2020 18:23:44 +0200
changeset 7780
41420f82c0ac
parent 7360
9190402e4505
child 7923
91e843545d9a
permissions
-rw-r--r--

Performed some code cleanup.

52
ba69827929ee Renamed E4Network to E5Network.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
ba69827929ee Renamed E4Network to E5Network.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
2
7360
9190402e4505 Updated copyright for 2020.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 7229
diff changeset
3 # Copyright (c) 2009 - 2020 Detlev Offenbach <detlev@die-offenbachs.de>
52
ba69827929ee Renamed E4Network to E5Network.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
4 #
ba69827929ee Renamed E4Network to E5Network.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
5
ba69827929ee Renamed E4Network to E5Network.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
6 """
4968
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
7 Package implementing some special network related objects and functions.
52
ba69827929ee Renamed E4Network to E5Network.
Detlev Offenbach <detlev@die-offenbachs.de>
parents:
diff changeset
8 """
4968
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
9
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
10 from PyQt5.QtNetwork import QAbstractSocket, QHostAddress
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
11
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
12
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
13 def isValidAddress(address):
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
14 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
15 Public function to check, if the given address is valid.
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
16
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
17 @param address IPv4 or IPv6 address string
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
18 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
19 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
20 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
21 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
22 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
23 return not h.isNull()
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
24
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
25
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
26 def isValidIPv4Address(address):
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
27 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
28 Public function to check, if the given address is a valid IPv4 address.
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
29
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
30 @param address IPv4 address string
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
31 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
32 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
33 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
34 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
35 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
36 return not h.isNull() and h.protocol() == QAbstractSocket.IPv4Protocol
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
37
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
38
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
39 def isValidIPv6Address(address):
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
40 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
41 Public function to check, if the given address is a valid IPv6 address.
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
42
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
43 @param address IPv6 address string
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
44 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
45 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
46 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
47 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
48 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
49 return not h.isNull() and h.protocol() == QAbstractSocket.IPv6Protocol

eric ide

mercurial