eric6/E5Network/__init__.py

Sun, 14 Apr 2019 15:09:21 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 14 Apr 2019 15:09:21 +0200
changeset 6942
2602857055c5
parent 6645
E5Network/__init__.py@ad476851d7e0
child 7229
53054eb5b15a
permissions
-rw-r--r--

Major restructuring of the source tree to get prepared for a setup.py based installation.

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
6645
ad476851d7e0 Updated copyright for 2019.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 6048
diff changeset
3 # Copyright (c) 2009 - 2019 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 __future__ import unicode_literals
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 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
13
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 def isValidAddress(address):
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 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
18
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
19 @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
20 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
21 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
22 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
23 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
24 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
25 return not h.isNull()
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
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
28 def isValidIPv4Address(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 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
31
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
32 @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
33 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
34 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
35 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
36 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
37 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
38 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
39
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 def isValidIPv6Address(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 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
44
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
45 @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
46 @type str
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
47 @return flag indicating validity
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
48 @rtype bool
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
49 """
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
50 h = QHostAddress(address)
afcc223b932f Added some utility functions to check a network address.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 4631
diff changeset
51 return not h.isNull() and h.protocol() == QAbstractSocket.IPv6Protocol

eric ide

mercurial