eric6/E5Network/__init__.py

Wed, 01 Jan 2020 11:57:23 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 01 Jan 2020 11:57:23 +0100
changeset 7360
9190402e4505
parent 7229
53054eb5b15a
child 7780
41420f82c0ac
permissions
-rw-r--r--

Updated copyright for 2020.

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
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
11 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
12
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
13
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
14 def isValidAddress(address):
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
15 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
16 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
17
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
18 @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
19 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
20 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
21 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
22 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
23 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
24 return not h.isNull()
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
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
27 def isValidIPv4Address(address):
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
28 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
29 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
30
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
31 @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
32 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
33 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
34 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
35 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
36 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
37 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
38
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
39
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
40 def isValidIPv6Address(address):
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
41 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
42 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
43
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
44 @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
45 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
46 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
47 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
48 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
49 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
50 return not h.isNull() and h.protocol() == QAbstractSocket.IPv6Protocol

eric ide

mercurial