]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
start resolver doco
authorBob Halley <halley@dnspython.org>
Mon, 16 Jan 2017 16:09:30 +0000 (08:09 -0800)
committerBob Halley <halley@dnspython.org>
Mon, 16 Jan 2017 16:09:30 +0000 (08:09 -0800)
dns/resolver.py
doc/exceptions.rst
doc/resolver-class.rst [new file with mode: 0644]
doc/resolver-override.rst [new file with mode: 0644]
doc/resolver.rst

index c647df432b67c9b4927ebdeef7e9fe1fe1dcb5f0..4ba171fe8f085ba393ea910093f838b4b2d1992d 100644 (file)
@@ -49,7 +49,6 @@ if sys.platform == 'win32':
         import _winreg  # pylint: disable=import-error
 
 class NXDOMAIN(dns.exception.DNSException):
-
     """The DNS query name does not exist."""
     supp_kwargs = set(['qnames', 'responses'])
     fmt = None  # we have our own __str__ implementation
@@ -109,7 +108,6 @@ class NXDOMAIN(dns.exception.DNSException):
 
 
 class YXDOMAIN(dns.exception.DNSException):
-
     """The DNS query name is too long after DNAME substitution."""
 
 # The definition of the Timeout exception has moved from here to the
@@ -120,7 +118,6 @@ Timeout = dns.exception.Timeout
 
 
 class NoAnswer(dns.exception.DNSException):
-
     """The DNS response does not contain an answer to the question."""
     fmt = 'The DNS response does not contain an answer ' + \
           'to the question: {query}'
@@ -132,7 +129,6 @@ class NoAnswer(dns.exception.DNSException):
 
 
 class NoNameservers(dns.exception.DNSException):
-
     """All nameservers failed to answer the query.
 
     errors: list of servers and respective errors
@@ -155,22 +151,18 @@ class NoNameservers(dns.exception.DNSException):
 
 
 class NotAbsolute(dns.exception.DNSException):
-
     """An absolute domain name is required but a relative name was provided."""
 
 
 class NoRootSOA(dns.exception.DNSException):
-
     """There is no SOA RR at the DNS root name. This should never happen!"""
 
 
 class NoMetaqueries(dns.exception.DNSException):
-
     """DNS metaqueries are not allowed."""
 
 
 class Answer(object):
-
     """DNS stub resolver answer
 
     Instances of this class bundle up the result of a successful DNS
@@ -289,7 +281,6 @@ class Answer(object):
 
 
 class Cache(object):
-
     """Simple DNS answer cache.
 
     @ivar data: A dictionary of cached data
@@ -387,9 +378,7 @@ class Cache(object):
 
 
 class LRUCacheNode(object):
-
-    """LRUCache node.
-    """
+    """LRUCache node."""
 
     def __init__(self, key, value):
         self.key = key
@@ -415,7 +404,6 @@ class LRUCacheNode(object):
 
 
 class LRUCache(object):
-
     """Bounded least-recently-used DNS answer cache.
 
     This cache is better than the simple cache (above) if you're
@@ -526,7 +514,6 @@ class LRUCache(object):
 
 
 class Resolver(object):
-
     """DNS stub resolver
 
     @ivar domain: The domain of this host
@@ -1383,9 +1370,9 @@ def override_system_resolver(resolver=None):
     The resolver to use may be specified; if it's not, the default
     resolver will be used.
 
-    @param resolver: the resolver to use
-    @type resolver: dns.resolver.Resolver object or None
+    resolver, a ``dns.resolver.Resolver`` or ``None``, the resolver to use.
     """
+
     if resolver is None:
         resolver = get_default_resolver()
     global _resolver
@@ -1399,8 +1386,8 @@ def override_system_resolver(resolver=None):
 
 
 def restore_system_resolver():
-    """Undo the effects of override_system_resolver().
-    """
+    """Undo the effects of prior override_system_resolver()."""
+
     global _resolver
     _resolver = None
     socket.getaddrinfo = _original_getaddrinfo
index 57d1d5f43a8da727c9c18bbacb547a4d9c8e5ee5..fdf0edd1012f6c5f2692646e366983142a9e18b0 100644 (file)
@@ -64,6 +64,17 @@ dns.rdataset Exceptions
 .. autoexception:: dns.rdataset.DifferingCovers
 .. autoexception:: dns.rdataset.IncompatibleTypes
 
+dns.resolver Exceptions
+-----------------------
+
+.. autoexception:: dns.resolver.NoAnswer
+.. autoexception:: dns.resolver.NoMetaqueries
+.. autoexception:: dns.resolver.NoNameservers
+.. autoexception:: dns.resolver.NoRootSOA
+.. autoexception:: dns.resolver.NotAbsolute
+.. autoexception:: dns.resolver.NXDOMAIN
+.. autoexception:: dns.resolver.YXDOMAIN
+
 dns.tokenizer Exceptions
 ------------------------
 
diff --git a/doc/resolver-class.rst b/doc/resolver-class.rst
new file mode 100644 (file)
index 0000000..3cf2be0
--- /dev/null
@@ -0,0 +1,13 @@
+.. _resolver-class:
+
+The dns.resolver.Resolver Class
+-------------------------------
+
+.. autoclass:: dns.resolver.Resolver
+   :members:
+
+   .. attribute:: domain
+
+      A ``dns.name.Name``, the domain of this host.
+
+   .. more attributes here!      
diff --git a/doc/resolver-override.rst b/doc/resolver-override.rst
new file mode 100644 (file)
index 0000000..271013f
--- /dev/null
@@ -0,0 +1,12 @@
+.. _resolver-override:
+
+Overriding the System Resolver
+------------------------------
+
+Sometimes it can be useful to make all of Python use dnspython's resolver
+rather than the default functionality in the ``socket`` module.  Dnspython
+can redefine the entires in the socket module to point at its own code, and
+it can also restore them back to the regular Python defaults.
+
+.. autofunction:: dns.resolver.override_system_resolver
+.. autofunction:: dns.resolver.restore_system_resolver
index 6fad36d805a84e1d5cf74c6ce6f2bb2970282c0d..dc4914e0fad9db08b577e2334efab2dac109bbb2 100644 (file)
@@ -6,3 +6,7 @@ Stub Resolver
 
 This is a placeholder.
 
+.. toctree::
+
+   resolver-class
+   resolver-override