Added some utility functions to check a network address.

Thu, 05 May 2016 19:50:00 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Thu, 05 May 2016 19:50:00 +0200
changeset 4968
afcc223b932f
parent 4967
d9edf6517263
child 4970
dcbb14191a3b

Added some utility functions to check a network address.

APIs/Python3/eric6.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric6.E5Network.__init__.html file | annotate | diff | comparison | revisions
Documentation/Source/index-eric6.E5Network.html file | annotate | diff | comparison | revisions
Documentation/Source/index-eric6.html file | annotate | diff | comparison | revisions
E5Network/__init__.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric6.api	Thu May 05 16:24:20 2016 +0200
+++ b/APIs/Python3/eric6.api	Thu May 05 19:50:00 2016 +0200
@@ -1797,6 +1797,9 @@
 eric6.E5Network.E5XmlRpcClient.E5XmlRpcClient.call?4(method, args, responseCallback, errorCallback)
 eric6.E5Network.E5XmlRpcClient.E5XmlRpcClient.setUrl?4(url)
 eric6.E5Network.E5XmlRpcClient.E5XmlRpcClient?1(url, parent=None)
+eric6.E5Network.isValidAddress?4(address)
+eric6.E5Network.isValidIPv4Address?4(address)
+eric6.E5Network.isValidIPv6Address?4(address)
 eric6.E5XML.Config.debuggerPropertiesFileFormatVersion?7
 eric6.E5XML.Config.highlightingStylesFileFormatVersion?7
 eric6.E5XML.Config.multiProjectFileFormatVersion?7
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Thu May 05 16:24:20 2016 +0200
+++ b/Documentation/Help/source.qhp	Thu May 05 19:50:00 2016 +0200
@@ -156,6 +156,7 @@
             <section title="eric6.E5Network.E5SslUtilities" ref="eric6.E5Network.E5SslUtilities.html" />
             <section title="eric6.E5Network.E5UrlInfo" ref="eric6.E5Network.E5UrlInfo.html" />
             <section title="eric6.E5Network.E5XmlRpcClient" ref="eric6.E5Network.E5XmlRpcClient.html" />
+            <section title="eric6.E5Network.__init__" ref="eric6.E5Network.__init__.html" />
           </section>
           <section title="eric6.E5XML" ref="index-eric6.E5XML.html">
             <section title="eric6.E5XML.Config" ref="eric6.E5XML.Config.html" />
@@ -16356,6 +16357,9 @@
       <keyword name="isLinuxPlatform" id="isLinuxPlatform" ref="eric6.Globals.__init__.html#isLinuxPlatform" />
       <keyword name="isMacPlatform" id="isMacPlatform" ref="eric6.Globals.__init__.html#isMacPlatform" />
       <keyword name="isTextFile" id="isTextFile" ref="eric6.Utilities.MimeTypes.html#isTextFile" />
+      <keyword name="isValidAddress" id="isValidAddress" ref="eric6.E5Network.__init__.html#isValidAddress" />
+      <keyword name="isValidIPv4Address" id="isValidIPv4Address" ref="eric6.E5Network.__init__.html#isValidIPv4Address" />
+      <keyword name="isValidIPv6Address" id="isValidIPv6Address" ref="eric6.E5Network.__init__.html#isValidIPv6Address" />
       <keyword name="isWindowsPlatform" id="isWindowsPlatform" ref="eric6.Globals.__init__.html#isWindowsPlatform" />
       <keyword name="is_binary_operator" id="is_binary_operator" ref="eric6.Plugins.CheckerPlugins.CodeStyleChecker.pep8.html#is_binary_operator" />
       <keyword name="is_stream_binary_plist" id="is_stream_binary_plist" ref="eric6.Utilities.binplistlib.html#is_stream_binary_plist" />
@@ -16781,6 +16785,7 @@
       <file>eric6.E5Network.E5SslUtilities.html</file>
       <file>eric6.E5Network.E5UrlInfo.html</file>
       <file>eric6.E5Network.E5XmlRpcClient.html</file>
+      <file>eric6.E5Network.__init__.html</file>
       <file>eric6.E5XML.Config.html</file>
       <file>eric6.E5XML.DebuggerPropertiesReader.html</file>
       <file>eric6.E5XML.DebuggerPropertiesWriter.html</file>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Documentation/Source/eric6.E5Network.__init__.html	Thu May 05 19:50:00 2016 +0200
@@ -0,0 +1,117 @@
+<!DOCTYPE html>
+<html><head>
+<title>eric6.E5Network.__init__</title>
+<meta charset="UTF-8">
+<style>
+body {
+    background: #EDECE6;
+    margin: 0em 1em 10em 1em;
+    color: black;
+}
+
+h1 { color: white; background: #85774A; }
+h2 { color: white; background: #85774A; }
+h3 { color: white; background: #9D936E; }
+h4 { color: white; background: #9D936E; }
+    
+a { color: #BA6D36; }
+
+</style>
+</head>
+<body><a NAME="top" ID="top"></a>
+<h1>eric6.E5Network.__init__</h1>
+<p>
+Package implementing some special network related objects and functions.
+</p>
+<h3>Global Attributes</h3>
+<table>
+<tr><td>None</td></tr>
+</table>
+<h3>Classes</h3>
+<table>
+<tr><td>None</td></tr>
+</table>
+<h3>Functions</h3>
+<table>
+<tr>
+<td><a href="#isValidAddress">isValidAddress</a></td>
+<td>Public function to check, if the given address is valid.</td>
+</tr><tr>
+<td><a href="#isValidIPv4Address">isValidIPv4Address</a></td>
+<td>Public function to check, if the given address is a valid IPv4 address.</td>
+</tr><tr>
+<td><a href="#isValidIPv6Address">isValidIPv6Address</a></td>
+<td>Public function to check, if the given address is a valid IPv6 address.</td>
+</tr>
+</table>
+<hr /><hr />
+<a NAME="isValidAddress" ID="isValidAddress"></a>
+<h2>isValidAddress</h2>
+<b>isValidAddress</b>(<i>address</i>)
+<p>
+    Public function to check, if the given address is valid.
+</p><dl>
+<dt><i>address</i> (str)</dt>
+<dd>
+IPv4 or IPv6 address string
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating validity
+</dd>
+</dl><dl>
+<dt>Return Type:</dt>
+<dd>
+bool
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
+<a NAME="isValidIPv4Address" ID="isValidIPv4Address"></a>
+<h2>isValidIPv4Address</h2>
+<b>isValidIPv4Address</b>(<i>address</i>)
+<p>
+    Public function to check, if the given address is a valid IPv4 address.
+</p><dl>
+<dt><i>address</i> (str)</dt>
+<dd>
+IPv4 address string
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating validity
+</dd>
+</dl><dl>
+<dt>Return Type:</dt>
+<dd>
+bool
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr /><hr />
+<a NAME="isValidIPv6Address" ID="isValidIPv6Address"></a>
+<h2>isValidIPv6Address</h2>
+<b>isValidIPv6Address</b>(<i>address</i>)
+<p>
+    Public function to check, if the given address is a valid IPv6 address.
+</p><dl>
+<dt><i>address</i> (str)</dt>
+<dd>
+IPv6 address string
+</dd>
+</dl><dl>
+<dt>Returns:</dt>
+<dd>
+flag indicating validity
+</dd>
+</dl><dl>
+<dt>Return Type:</dt>
+<dd>
+bool
+</dd>
+</dl>
+<div align="right"><a href="#top">Up</a></div>
+<hr />
+</body></html>
\ No newline at end of file
--- a/Documentation/Source/index-eric6.E5Network.html	Thu May 05 16:24:20 2016 +0200
+++ b/Documentation/Source/index-eric6.E5Network.html	Thu May 05 19:50:00 2016 +0200
@@ -21,7 +21,7 @@
 <body>
 <h1>eric6.E5Network</h1>
 <p>
-Package implementing some special network related objects.
+Package implementing some special network related objects and functions.
 </p>
 
 
@@ -69,6 +69,9 @@
 </tr><tr>
 <td><a href="eric6.E5Network.E5XmlRpcClient.html">E5XmlRpcClient</a></td>
 <td>Module implementing a xmlrpc client for Qt.</td>
+</tr><tr>
+<td><a href="eric6.E5Network.__init__.html">E5Network</a></td>
+<td>Package implementing some special network related objects and functions.</td>
 </tr>
 </table>
 </body></html>
\ No newline at end of file
--- a/Documentation/Source/index-eric6.html	Thu May 05 16:24:20 2016 +0200
+++ b/Documentation/Source/index-eric6.html	Thu May 05 19:50:00 2016 +0200
@@ -52,7 +52,7 @@
 <td>Package implementing some special GUI elements.</td>
 </tr><tr>
 <td><a href="index-eric6.E5Network.html">E5Network</a></td>
-<td>Package implementing some special network related objects.</td>
+<td>Package implementing some special network related objects and functions.</td>
 </tr><tr>
 <td><a href="index-eric6.E5XML.html">E5XML</a></td>
 <td>Package implementing the XML handling module of eric6.</td>
--- a/E5Network/__init__.py	Thu May 05 16:24:20 2016 +0200
+++ b/E5Network/__init__.py	Thu May 05 19:50:00 2016 +0200
@@ -4,5 +4,48 @@
 #
 
 """
-Package implementing some special network related objects.
+Package implementing some special network related objects and functions.
 """
+
+from __future__ import unicode_literals
+
+from PyQt5.QtNetwork import QAbstractSocket, QHostAddress
+
+
+def isValidAddress(address):
+    """
+    Public function to check, if the given address is valid.
+    
+    @param address IPv4 or IPv6 address string
+    @type str
+    @return flag indicating validity
+    @rtype bool
+    """
+    h = QHostAddress(address)
+    return not h.isNull()
+
+
+def isValidIPv4Address(address):
+    """
+    Public function to check, if the given address is a valid IPv4 address.
+    
+    @param address IPv4 address string
+    @type str
+    @return flag indicating validity
+    @rtype bool
+    """
+    h = QHostAddress(address)
+    return not h.isNull() and h.protocol() == QAbstractSocket.IPv4Protocol
+
+
+def isValidIPv6Address(address):
+    """
+    Public function to check, if the given address is a valid IPv6 address.
+    
+    @param address IPv6 address string
+    @type str
+    @return flag indicating validity
+    @rtype bool
+    """
+    h = QHostAddress(address)
+    return not h.isNull() and h.protocol() == QAbstractSocket.IPv6Protocol

eric ide

mercurial