start of test driver impl.
[python-rwhoisd.git] / rwhoisd / Cidr.py
index 88d46d3..fb86a10 100644 (file)
@@ -37,6 +37,20 @@ def new(address, netlen = -1):
         return CidrV6(address, netlen)
     return CidrV4(address, netlen)
 
+def valid_cidr(address):
+    """Returns the converted Cidr object if 'address' is valid CIDR
+    notation, False if not.  For the purposes of this module, valid
+    CIDR notation consists of a IPv4 or IPv6 address with an optional
+    trailing "/netlen"."""
+
+    if isinstance(address, Cidr): return address
+    try:
+        c = new(address)
+        return c
+    except (ValueError, socket.error):
+        return False
+
+
 class Cidr:
     """A class representing a generic CIDRized network value."""
 
@@ -246,19 +260,6 @@ class CidrV6(Cidr):
         return self._base_mask(CidrV6.base_mask << (128 - len))
 
 
-def valid_cidr(address):
-    """Returns the converted Cidr object if 'address' is valid CIDR
-    notation, False if not.  For the purposes of this module, valid
-    CIDR notation consists of a IPv4 or IPv6 address with an optional
-    trailing "/netlen"."""
-
-    if isinstance(address, Cidr): return address
-    try:
-        c = new(address)
-        return c
-    except (ValueError, socket.error):
-        return False
-
 def netblock_to_cidr(start, end):
     """Convert an arbitrary network block expressed as a start and end
     address (inclusive) into a series of valid CIDR blocks."""