]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
continue doco overhaul
authorBob Halley <halley@dnspython.org>
Tue, 10 Jan 2017 22:56:57 +0000 (14:56 -0800)
committerBob Halley <halley@dnspython.org>
Tue, 10 Jan 2017 22:56:57 +0000 (14:56 -0800)
dns/rcode.py
dns/rdataset.py
dns/rrset.py
doc/exceptions.rst
doc/rdata-set-classes.rst

index 314815f7c5aa9dfbff0b82b815fb49d42465f8e8..eb4d1d6b8ac78ef4036eb12e4dbc37bb925123c5 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc.
+# Copyright (C) 2001-2017 Nominum, Inc.
 #
 # Permission to use, copy, modify, and distribute this software and its
 # documentation for any purpose with or without fee is hereby granted,
 import dns.exception
 from ._compat import long
 
-
+#: No error
 NOERROR = 0
+#: Form error
 FORMERR = 1
+#: Server failure
 SERVFAIL = 2
+#: Name does not exist ("Name Error" in RFC 1025 terminology).
 NXDOMAIN = 3
+#: Not implemented
 NOTIMP = 4
+#: Refused
 REFUSED = 5
+#: Name exists.
 YXDOMAIN = 6
+#: RRset exists.
 YXRRSET = 7
+#: RRset does not exist.
 NXRRSET = 8
+#: Not authoritative.
 NOTAUTH = 9
+#: Name not in zone.
 NOTZONE = 10
+#: Bad EDNS version.
 BADVERS = 16
 
 _by_text = {
@@ -55,17 +66,17 @@ _by_value = dict((y, x) for x, y in _by_text.items())
 
 
 class UnknownRcode(dns.exception.DNSException):
-
     """A DNS rcode is unknown."""
 
 
 def from_text(text):
     """Convert text into an rcode.
 
-    @param text: the textual rcode
-    @type text: string
-    @raises UnknownRcode: the rcode is unknown
-    @rtype: int
+    *text*, a ``text``, the textual rcode or an integer in textual form.
+
+    Raises ``dns.rcode.UnknownRcode`` if the rcode mnemonic is unknown.
+
+    Returns an ``int``.
     """
 
     if text.isdigit():
@@ -81,12 +92,13 @@ def from_text(text):
 def from_flags(flags, ednsflags):
     """Return the rcode value encoded by flags and ednsflags.
 
-    @param flags: the DNS flags
-    @type flags: int
-    @param ednsflags: the EDNS flags
-    @type ednsflags: int
-    @raises ValueError: rcode is < 0 or > 4095
-    @rtype: int
+    *flags*, an ``int``, the DNS flags field.
+
+    *ednsflags*, an ``int``, the EDNS flags field.
+
+    Raises ``ValueError`` if rcode is < 0 or > 4095
+
+    Returns an ``int``.
     """
 
     value = (flags & 0x000f) | ((ednsflags >> 20) & 0xff0)
@@ -98,10 +110,11 @@ def from_flags(flags, ednsflags):
 def to_flags(value):
     """Return a (flags, ednsflags) tuple which encodes the rcode.
 
-    @param value: the rcode
-    @type value: int
-    @raises ValueError: rcode is < 0 or > 4095
-    @rtype: (int, int) tuple
+    *value*, an ``int``, the rcode.
+
+    Raises ``ValueError`` if rcode is < 0 or > 4095.
+
+    Returns an ``(int, int)`` tuple.
     """
 
     if value < 0 or value > 4095:
@@ -114,11 +127,15 @@ def to_flags(value):
 def to_text(value):
     """Convert rcode into text.
 
-    @param value: the rcode
-    @type value: int
-    @rtype: string
+    *value*, and ``int``, the rcode.
+
+    Raises ``ValueError`` if rcode is < 0 or > 4095.
+
+    Returns a ``text``.
     """
 
+    if value < 0 or value > 4095:
+        raise ValueError('rcode must be >= 0 and <= 4095')
     text = _by_value.get(value)
     if text is None:
         text = str(value)
index db266f2f09e2faf5a25843ccb19ab92d89310e25..9f0825e21e2deccd970e7e608d33fd44b43bd5a0 100644 (file)
@@ -285,7 +285,7 @@ def from_text_list(rdclass, rdtype, ttl, text_rdatas):
     """Create an rdataset with the specified class, type, and TTL, and with
     the specified list of rdatas in text format.
 
-    @rtype: dns.rdataset.Rdataset object
+    Returns a ``dns.rdataset.Rdataset`` object.
     """
 
     if isinstance(rdclass, string_types):
@@ -304,7 +304,7 @@ def from_text(rdclass, rdtype, ttl, *text_rdatas):
     """Create an rdataset with the specified class, type, and TTL, and with
     the specified rdatas in text format.
 
-    @rtype: dns.rdataset.Rdataset object
+    Returns a ``dns.rdataset.Rdataset`` object.
     """
 
     return from_text_list(rdclass, rdtype, ttl, text_rdatas)
@@ -314,7 +314,7 @@ def from_rdata_list(ttl, rdatas):
     """Create an rdataset with the specified TTL, and with
     the specified list of rdata objects.
 
-    @rtype: dns.rdataset.Rdataset object
+    Returns a ``dns.rdataset.Rdataset`` object.
     """
 
     if len(rdatas) == 0:
@@ -332,7 +332,7 @@ def from_rdata(ttl, *rdatas):
     """Create an rdataset with the specified TTL, and with
     the specified rdata objects.
 
-    @rtype: dns.rdataset.Rdataset object
+    Returns a ``dns.rdataset.Rdataset`` object.
     """
 
     return from_rdata_list(ttl, rdatas)
index d0f8f93776063d03d5d52bd5f9c589a27948abf6..30086453c8310f89d17951db95e38840615ad7c4 100644 (file)
@@ -124,7 +124,7 @@ def from_text_list(name, ttl, rdclass, rdtype, text_rdatas,
     """Create an RRset with the specified name, TTL, class, and type, and with
     the specified list of rdatas in text format.
 
-    @rtype: dns.rrset.RRset object
+    Returns a ``dns.rrset.RRset`` object.
     """
 
     if isinstance(name, string_types):
@@ -145,7 +145,7 @@ def from_text(name, ttl, rdclass, rdtype, *text_rdatas):
     """Create an RRset with the specified name, TTL, class, and type and with
     the specified rdatas in text format.
 
-    @rtype: dns.rrset.RRset object
+    Returns a ``dns.rrset.RRset`` object.
     """
 
     return from_text_list(name, ttl, rdclass, rdtype, text_rdatas)
@@ -155,7 +155,7 @@ def from_rdata_list(name, ttl, rdatas, idna_codec=None):
     """Create an RRset with the specified name and TTL, and with
     the specified list of rdata objects.
 
-    @rtype: dns.rrset.RRset object
+    Returns a ``dns.rrset.RRset`` object.
     """
 
     if isinstance(name, string_types):
@@ -176,7 +176,7 @@ def from_rdata(name, ttl, *rdatas):
     """Create an RRset with the specified name and TTL, and with
     the specified rdata objects.
 
-    @rtype: dns.rrset.RRset object
+    Returns a ``dns.rrset.RRset`` object.
     """
 
     return from_rdata_list(name, ttl, rdatas)
index 1eb856fbd8ad4f4cfb72e9128bcb58c730e0afb2..8c5c003a84cc95efd41d058b0d7085099039f3d9 100644 (file)
@@ -1,13 +1,16 @@
 .. _exceptions:
 
+Exceptions
+==========
+
 Common Exceptions
-=================
+-----------------
 
 .. automodule:: dns.exception
    :members:
 
 dns.name Exceptions
-===================
+-------------------
 
 .. autoexception:: dns.name.AbsoluteConcatenation
 .. autoexception:: dns.name.BadEscape
@@ -21,8 +24,13 @@ dns.name Exceptions
 .. autoexception:: dns.name.NoIDNA2008
 .. autoexception:: dns.name.NoParent
 
+dns.rcode Exceptions
+--------------------
+
+.. autoexception:: dns.rcode.UnknownRcode
+
 dns.rdataset Exceptions
-=======================
+-----------------------
                    
 .. autoexception:: dns.rdataset.DifferingCovers
 .. autoexception:: dns.rdataset.IncompatibleTypes
index 5a953c890263fddc07f5889ba0b9f37812d27b3c..c66df396854ed2ac7196cbc4be225bcab1347fe8 100644 (file)
@@ -1,7 +1,7 @@
 .. _rdata-set-classes:
 
-DNS Rdataset Class
-==================
+Rdataset and RRset Classes
+==========================
 
 An ``Rdataset`` is a set of ``Rdata`` objects which all have the same
 rdatatype, rdataclass, and covered type.  ``Rdatasets`` also have a