Ticket #4685: resolver-docs-4685.patch

File resolver-docs-4685.patch, 52.0 KB (added by Richard Wall, 7 years ago)

Various twisted.names docstring improvements

  • twisted/internet/interfaces.py

    === modified file 'twisted/internet/interfaces.py'
     
    5656
    5757class IResolverSimple(Interface):
    5858
    59     def getHostByName(name, timeout = (1, 3, 11, 45)):
     59    def getHostByName(name, timeout=None, effort=10):
    6060        """
    6161        Resolve the domain name C{name} into an IP address.
    6262
     63        Will errback with C{DNSQueryTimeoutError} on a timeout,
     64        C{DomainError} or C{AuthoritativeDomainError} (or subclasses)
     65        on other errors.
     66
    6367        @type name: C{str}
    64         @type timeout: C{tuple}
     68        @param name: DNS name to resolve.
     69
     70        @type timeout: C{None} or sequence of C{int}
     71        @param timeout: Number of seconds after which to reissue the
     72        query.  When the last timeout expires, the query is considered
     73        failed.
     74
     75        @type effort: C{int}
     76        @param effort: How many times CNAME and NS records to follow
     77        while resolving this name.
     78
    6579        @rtype: L{twisted.internet.defer.Deferred}
    6680        @return: The callback of the Deferred that is returned will be
    67         passed a string that represents the IP address of the specified
    68         name, or the errback will be called if the lookup times out.  If
    69         multiple types of address records are associated with the name,
    70         A6 records will be returned in preference to AAAA records, which
    71         will be returned in preference to A records.  If there are multiple
    72         records of the type to be returned, one will be selected at random.
     81        passed a string that represents the IP address of the
     82        specified name, or the errback will be called if the lookup
     83        times out.  If multiple types of address records are
     84        associated with the name, A6 records will be returned in
     85        preference to AAAA records, which will be returned in
     86        preference to A records.  If there are multiple records of the
     87        type to be returned, one will be selected at random.
    7388
    7489        @raise twisted.internet.defer.TimeoutError: Raised (asynchronously)
    7590        if the name cannot be resolved within the specified timeout period.
    7691        """
    7792
     93
    7894class IResolver(IResolverSimple):
    79     def lookupRecord(name, cls, type, timeout = 10):
    80         """
    81         Lookup the records associated with the given name
    82         that are of the given type and in the given class.
    83         """
    84 
    85     def query(query, timeout = 10):
     95    def query(query, timeout=None):
    8696        """
    8797        Interpret and dispatch a query object to the appropriate
    8898        lookup* method.
    89         """
    90 
    91     def lookupAddress(name, timeout = 10):
    92         """
    93         Lookup the A records associated with C{name}.
    94         """
    95 
    96     def lookupAddress6(name, timeout = 10):
    97         """
    98         Lookup all the A6 records associated with C{name}.
    99         """
    100 
    101     def lookupIPV6Address(name, timeout = 10):
    102         """
    103         Lookup all the AAAA records associated with C{name}.
    104         """
    105 
    106     def lookupMailExchange(name, timeout = 10):
    107         """
    108         Lookup the MX records associated with C{name}.
    109         """
    110 
    111     def lookupNameservers(name, timeout = 10):
    112         """
    113         Lookup the the NS records associated with C{name}.
    114         """
    115 
    116     def lookupCanonicalName(name, timeout = 10):
    117         """
    118         Lookup the CNAME records associated with C{name}.
    119         """
    120 
    121     def lookupMailBox(name, timeout = 10):
    122         """
    123         Lookup the MB records associated with C{name}.
    124         """
    125 
    126     def lookupMailGroup(name, timeout = 10):
    127         """
    128         Lookup the MG records associated with C{name}.
    129         """
    130 
    131     def lookupMailRename(name, timeout = 10):
    132         """
    133         Lookup the MR records associated with C{name}.
    134         """
    135 
    136     def lookupPointer(name, timeout = 10):
    137         """
    138         Lookup the PTR records associated with C{name}.
    139         """
    140 
    141     def lookupAuthority(name, timeout = 10):
    142         """
    143         Lookup the SOA records associated with C{name}.
    144         """
    145 
    146     def lookupNull(name, timeout = 10):
    147         """
    148         Lookup the NULL records associated with C{name}.
    149         """
    150 
    151     def lookupWellKnownServices(name, timeout = 10):
    152         """
    153         Lookup the WKS records associated with C{name}.
    154         """
    155 
    156     def lookupHostInfo(name, timeout = 10):
    157         """
    158         Lookup the HINFO records associated with C{name}.
    159         """
    160 
    161     def lookupMailboxInfo(name, timeout = 10):
    162         """
    163         Lookup the MINFO records associated with C{name}.
    164         """
    165 
    166     def lookupText(name, timeout = 10):
    167         """
    168         Lookup the TXT records associated with C{name}.
    169         """
    170 
    171     def lookupResponsibility(name, timeout = 10):
    172         """
    173         Lookup the RP records associated with C{name}.
    174         """
    175 
    176     def lookupAFSDatabase(name, timeout = 10):
    177         """
    178         Lookup the AFSDB records associated with C{name}.
    179         """
    180 
    181     def lookupService(name, timeout = 10):
    182         """
    183         Lookup the SRV records associated with C{name}.
    184         """
    185 
    186     def lookupAllRecords(name, timeout = 10):
    187         """
    188         Lookup all records associated with C{name}.
    189         """
    190 
    191     def lookupZone(name, timeout = 10):
    192         """
    193         Perform a zone transfer for the given C{name}.
    194         """
    195 
     99
     100        @type query: L{twisted.named.dns.Query}
     101        @param query: A query object which will be dispatched to the
     102        appropriate lookup* method
     103       
     104        @type timeout: C{None} or sequence of C{int}
     105        @param timeout: Number of seconds after which to reissue the
     106        query.  When the last timeout expires, the query is considered
     107        failed.
     108
     109        @rtype: L{Deferred}
     110        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     111        authority, additional) lists, where each is a list of
     112        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     113        if the response code is anything other than C{dns.OK}.
     114        """
     115
     116    def lookupAddress(name, timeout=None):
     117        """
     118        Perform an A record lookup.
     119
     120        @type name: C{str}
     121        @param name: DNS name to resolve.
     122
     123        @type timeout: C{None} or sequence of C{int}
     124        @param timeout: Number of seconds after which to reissue the
     125        query.  When the last timeout expires, the query is considered
     126        failed.
     127
     128        @rtype: L{Deferred}
     129        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     130        authority, additional) lists, where each is a list of
     131        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     132        if the response code is anything other than C{dns.OK}.
     133        """
     134
     135    def lookupAddress6(name, timeout=None):
     136        """
     137        Perform an A6 record lookup.
     138
     139        @type name: C{str}
     140        @param name: DNS name to resolve.
     141
     142        @type timeout: C{None} or sequence of C{int}
     143        @param timeout: Number of seconds after which to reissue the
     144        query.  When the last timeout expires, the query is considered
     145        failed.
     146
     147        @rtype: L{Deferred}
     148        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     149        authority, additional) lists, where each is a list of
     150        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     151        if the response code is anything other than C{dns.OK}.
     152        """
     153
     154    def lookupIPV6Address(name, timeout=None):
     155        """
     156        Perform an AAAA record lookup.
     157
     158        @type name: C{str}
     159        @param name: DNS name to resolve.
     160
     161        @type timeout: C{None} or sequence of C{int}
     162        @param timeout: Number of seconds after which to reissue the
     163        query.  When the last timeout expires, the query is considered
     164        failed.
     165
     166        @rtype: L{Deferred}
     167        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     168        authority, additional) lists, where each is a list of
     169        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     170        if the response code is anything other than C{dns.OK}.
     171        """
     172
     173    def lookupMailExchange(name, timeout=None):
     174        """
     175        Perform an MX record lookup.
     176
     177        @type name: C{str}
     178        @param name: DNS name to resolve.
     179
     180        @type timeout: C{None} or sequence of C{int}
     181        @param timeout: Number of seconds after which to reissue the
     182        query.  When the last timeout expires, the query is considered
     183        failed.
     184
     185        @rtype: L{Deferred}
     186        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     187        authority, additional) lists, where each is a list of
     188        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     189        if the response code is anything other than C{dns.OK}.
     190        """
     191
     192    def lookupNameservers(name, timeout=None):
     193        """
     194        Perform an NS record lookup.
     195
     196        @type name: C{str}
     197        @param name: DNS name to resolve.
     198
     199        @type timeout: C{None} or sequence of C{int}
     200        @param timeout: Number of seconds after which to reissue the
     201        query.  When the last timeout expires, the query is considered
     202        failed.
     203
     204        @rtype: L{Deferred}
     205        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     206        authority, additional) lists, where each is a list of
     207        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     208        if the response code is anything other than C{dns.OK}.
     209        """
     210
     211    def lookupCanonicalName(name, timeout=None):
     212        """
     213        Perform a CNAME record lookup.
     214
     215        @type name: C{str}
     216        @param name: DNS name to resolve.
     217
     218        @type timeout: C{None} or sequence of C{int}
     219        @param timeout: Number of seconds after which to reissue the
     220        query.  When the last timeout expires, the query is considered
     221        failed.
     222
     223        @rtype: L{Deferred}
     224        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     225        authority, additional) lists, where each is a list of
     226        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     227        if the response code is anything other than C{dns.OK}.
     228        """
     229
     230    def lookupMailBox(name, timeout=None):
     231        """
     232        Perform an MB record lookup.
     233
     234        @type name: C{str}
     235        @param name: DNS name to resolve.
     236
     237        @type timeout: C{None} or sequence of C{int}
     238        @param timeout: Number of seconds after which to reissue the
     239        query.  When the last timeout expires, the query is considered
     240        failed.
     241
     242        @rtype: L{Deferred}
     243        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     244        authority, additional) lists, where each is a list of
     245        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     246        if the response code is anything other than C{dns.OK}.
     247        """
     248
     249    def lookupMailGroup(name, timeout=None):
     250        """
     251        Perform an MG record lookup.
     252
     253        @type name: C{str}
     254        @param name: DNS name to resolve.
     255
     256        @type timeout: C{None} or sequence of C{int}
     257        @param timeout: Number of seconds after which to reissue the
     258        query.  When the last timeout expires, the query is considered
     259        failed.
     260
     261        @rtype: L{Deferred}
     262        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     263        authority, additional) lists, where each is a list of
     264        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     265        if the response code is anything other than C{dns.OK}.
     266        """
     267
     268    def lookupMailRename(name, timeout=None):
     269        """
     270        Perform an MR record lookup.
     271
     272        @type name: C{str}
     273        @param name: DNS name to resolve.
     274
     275        @type timeout: C{None} or sequence of C{int}
     276        @param timeout: Number of seconds after which to reissue the
     277        query.  When the last timeout expires, the query is considered
     278        failed.
     279
     280        @rtype: L{Deferred}
     281        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     282        authority, additional) lists, where each is a list of
     283        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     284        if the response code is anything other than C{dns.OK}.
     285        """
     286
     287    def lookupPointer(name, timeout=None):
     288        """
     289        Perform a PTR record lookup.
     290
     291        @type name: C{str}
     292        @param name: DNS name to resolve.
     293
     294        @type timeout: C{None} or sequence of C{int}
     295        @param timeout: Number of seconds after which to reissue the
     296        query.  When the last timeout expires, the query is considered
     297        failed.
     298
     299        @rtype: L{Deferred}
     300        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     301        authority, additional) lists, where each is a list of
     302        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     303        if the response code is anything other than C{dns.OK}.
     304        """
     305
     306    def lookupAuthority(name, timeout=None):
     307        """
     308        Perform an SOA record lookup.
     309
     310        @type name: C{str}
     311        @param name: DNS name to resolve.
     312
     313        @type timeout: C{None} or sequence of C{int}
     314        @param timeout: Number of seconds after which to reissue the
     315        query.  When the last timeout expires, the query is considered
     316        failed.
     317
     318        @rtype: L{Deferred}
     319        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     320        authority, additional) lists, where each is a list of
     321        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     322        if the response code is anything other than C{dns.OK}.
     323        """
     324
     325    def lookupNull(name, timeout=None):
     326        """
     327        Perform a NULL record lookup.
     328
     329        @type name: C{str}
     330        @param name: DNS name to resolve.
     331
     332        @type timeout: C{None} or sequence of C{int}
     333        @param timeout: Number of seconds after which to reissue the
     334        query.  When the last timeout expires, the query is considered
     335        failed.
     336
     337        @rtype: L{Deferred}
     338        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     339        authority, additional) lists, where each is a list of
     340        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     341        if the response code is anything other than C{dns.OK}.
     342        """
     343
     344    def lookupWellKnownServices(name, timeout=None):
     345        """
     346        Perform a WKS record lookup.
     347
     348        @type name: C{str}
     349        @param name: DNS name to resolve.
     350
     351        @type timeout: C{None} or sequence of C{int}
     352        @param timeout: Number of seconds after which to reissue the
     353        query.  When the last timeout expires, the query is considered
     354        failed.
     355
     356        @rtype: L{Deferred}
     357        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     358        authority, additional) lists, where each is a list of
     359        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     360        if the response code is anything other than C{dns.OK}.
     361        """
     362
     363    def lookupHostInfo(name, timeout=None):
     364        """
     365        Perform a HINFO record lookup.
     366
     367        @type name: C{str}
     368        @param name: DNS name to resolve.
     369
     370        @type timeout: C{None} or sequence of C{int}
     371        @param timeout: Number of seconds after which to reissue the
     372        query.  When the last timeout expires, the query is considered
     373        failed.
     374
     375        @rtype: L{Deferred}
     376        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     377        authority, additional) lists, where each is a list of
     378        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     379        if the response code is anything other than C{dns.OK}.
     380        """
     381
     382    def lookupMailboxInfo(name, timeout=None):
     383        """
     384        Perform an MINFO record lookup.
     385
     386        @type name: C{str}
     387        @param name: DNS name to resolve.
     388
     389        @type timeout: C{None} or sequence of C{int}
     390        @param timeout: Number of seconds after which to reissue the
     391        query.  When the last timeout expires, the query is considered
     392        failed.
     393
     394        @rtype: L{Deferred}
     395        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     396        authority, additional) lists, where each is a list of
     397        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     398        if the response code is anything other than C{dns.OK}.
     399        """
     400
     401    def lookupText(name, timeout=None):
     402        """
     403        Perform a TXT record lookup.
     404
     405        @type name: C{str}
     406        @param name: DNS name to resolve.
     407
     408        @type timeout: C{None} or sequence of C{int}
     409        @param timeout: Number of seconds after which to reissue the query.
     410        When the last timeout expires, the query is considered failed.
     411
     412        @rtype: L{Deferred}
     413        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     414        authority, additional) lists, where each is a list of
     415        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     416        if the response code is anything other than C{dns.OK}.
     417        """
     418
     419    def lookupSenderPolicy(name, timeout=None):
     420        """
     421        Perform a SPF record lookup.
     422
     423        @type name: C{str}
     424        @param name: DNS name to resolve.
     425
     426        @type timeout: C{None} or sequence of C{int}
     427        @param timeout: Number of seconds after which to reissue the
     428        query.  When the last timeout expires, the query is considered
     429        failed.
     430
     431        @rtype: L{Deferred}
     432        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     433        authority, additional) lists, where each is a list of
     434        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     435        if the response code is anything other than C{dns.OK}.
     436        """
     437
     438    def lookupResponsibility(name, timeout=None):
     439        """
     440        Perform an RP record lookup.
     441
     442        @type name: C{str}
     443        @param name: DNS name to resolve.
     444
     445        @type timeout: C{None} or sequence of C{int}
     446        @param timeout: Number of seconds after which to reissue the query.
     447        When the last timeout expires, the query is considered failed.
     448
     449        @rtype: L{Deferred}
     450        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     451        authority, additional) lists, where each is a list of
     452        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     453        if the response code is anything other than C{dns.OK}.
     454        """
     455
     456    def lookupAFSDatabase(name, timeout=None):
     457        """
     458        Perform an AFSDB record lookup.
     459
     460        @type name: C{str}
     461        @param name: DNS name to resolve.
     462
     463        @type timeout: C{None} or sequence of C{int}
     464        @param timeout: Number of seconds after which to reissue the
     465        query.  When the last timeout expires, the query is considered
     466        failed.
     467
     468        @rtype: L{Deferred}
     469        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     470        authority, additional) lists, where each is a list of
     471        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     472        if the response code is anything other than C{dns.OK}.
     473        """
     474
     475    def lookupService(name, timeout=None):
     476        """
     477        Perform an SRV record lookup.
     478
     479        @type name: C{str}
     480        @param name: DNS name to resolve.
     481
     482        @type timeout: C{None} or sequence of C{int}
     483        @param timeout: Number of seconds after which to reissue the
     484        query.  When the last timeout expires, the query is considered
     485        failed.
     486
     487        @rtype: L{Deferred}
     488        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     489        authority, additional) lists, where each is a list of
     490        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     491        if the response code is anything other than C{dns.OK}.
     492        """
     493
     494    def lookupAllRecords(name, timeout=None):
     495        """
     496        ALL_RECORD lookup.
     497
     498        @type name: C{str}
     499        @param name: DNS name to resolve.
     500
     501        @type timeout: C{None} or sequence of C{int}
     502        @param timeout: Number of seconds after which to reissue the
     503        query.  When the last timeout expires, the query is considered
     504        failed.
     505
     506        @rtype: L{Deferred}
     507        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     508        authority, additional) lists, where each is a list of
     509        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     510        if the response code is anything other than C{dns.OK}.
     511        """
     512
     513    def lookupNamingAuthorityPointer(name, timeout=None):
     514        """
     515        Perform a NAPTR lookup.
     516
     517        @type name: C{str}
     518        @param name: DNS name to resolve.
     519
     520        @type timeout: C{None} or sequence of C{int}
     521        @param timeout: Number of seconds after which to reissue the
     522        query.  When the last timeout expires, the query is considered
     523        failed.
     524
     525        @rtype: L{Deferred}
     526        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     527        authority, additional) lists, where each is a list of
     528        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     529        if the response code is anything other than C{dns.OK}.
     530        """
     531
     532    def lookupZone(name, timeout=10):
     533        """
     534        Perform an AXFR record lookup.
     535
     536        This is quite different from usual DNS requests.
     537        AXFR lookups always use TCP, never UDP.
     538       
     539        @See: U{http://cr.yp.to/djbdns/axfr-notes.html} for more information.
     540
     541        @type name: C{str}
     542        @param name: DNS name to resolve.
     543
     544        @type timeout: C{int}
     545        @param timeout: When this timeout expires, the query is
     546        considered failed.
     547
     548        @rtype: L{Deferred}
     549        @returns: a L{Deferred} that fires with a 3-tuple of (results,
     550        authority, additional) lists, where each is a list of
     551        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     552        if the response code is anything other than C{dns.OK}.
     553        """
    196554
    197555
    198556class IReactorTCP(Interface):
     
    16642022        @param contextFactory: A context factory (see L{ssl.py<twisted.internet.ssl>})
    16652023        """
    16662024
     2025
     2026
    16672027class ISSLTransport(ITCPTransport):
    16682028    """
    16692029    A SSL/TLS based transport.
  • twisted/names/cache.py

    === modified file 'twisted/names/cache.py'
     
    1717    @ivar _reactor: A provider of L{interfaces.IReactorTime}.
    1818    """
    1919
    20     implements(interfaces.IResolver)
    21 
    2220    cache = None
    2321
    2422    def __init__(self, cache=None, verbose=0, reactor=None):
  • twisted/names/client.py

    === modified file 'twisted/names/client.py'
     
    2222import errno
    2323import warnings
    2424
    25 from zope.interface import implements
    26 
    2725# Twisted imports
    2826from twisted.python.runtime import platform
    29 from twisted.internet import error, defer, protocol, interfaces
     27from twisted.internet import error, defer, protocol
    3028from twisted.python import log, failure
    3129from twisted.python.deprecate import getWarningMethod
    3230from twisted.names import dns, common
     
    4644        L{IReactorTime} which will be used to set up network resources and
    4745        track timeouts.
    4846    """
    49     implements(interfaces.IResolver)
    5047
    5148    index = 0
    5249    timeout = None
     
    7168    protocol = property(_getProtocol)
    7269
    7370
    74     def __init__(self, resolv=None, servers=None, timeout=(1, 3, 11, 45), reactor=None):
     71    def __init__(self, resolv=None, servers=None, timeout=(1, 3, 11, 45),
     72                 reactor=None):
    7573        """
    7674        Construct a resolver which will query domain name servers listed in
    7775        the C{resolv.conf(5)}-format file given by C{resolv} as well as
     
    117115        self.resolv = resolv
    118116
    119117        if not len(self.servers) and not resolv:
    120             raise ValueError, "No nameservers specified"
     118            raise ValueError("No nameservers specified")
    121119
    122120        self.factory = DNSClientFactory(self, timeout)
    123121        self.factory.noisy = 0   # Be quiet by default
     
    151149            resolvConf = file(self.resolv)
    152150        except IOError, e:
    153151            if e.errno == errno.ENOENT:
    154                 # Missing resolv.conf is treated the same as an empty resolv.conf
     152                # Missing resolv.conf is treated the same as an empty
     153                # resolv.conf
    155154                self.parseConfig(())
    156155            else:
    157156                raise
     
    253252            self.connections.remove(protocol)
    254253
    255254
    256     def messageReceived(self, message, protocol, address = None):
    257         log.msg("Unexpected message (%d) received from %r" % (message.id, address))
     255    def messageReceived(self, message, protocol, address=None):
     256        log.msg(
     257            "Unexpected message (%d) "
     258            "received from %r" % (message.id, address))
    258259
    259260
    260261    def _query(self, *args):
     
    271272        """
    272273        protocol = self._connectedProtocol()
    273274        d = protocol.query(*args)
     275
    274276        def cbQueried(result):
    275277            protocol.transport.stopListening()
    276278            return result
     279
    277280        d.addBoth(cbQueried)
    278281        return d
    279282
    280283
    281     def queryUDP(self, queries, timeout = None):
     284    def queryUDP(self, queries, timeout=None):
    282285        """
    283286        Make a number of DNS queries via UDP.
    284287
    285288        @type queries: A C{list} of C{dns.Query} instances
    286289        @param queries: The queries to make.
    287290
    288         @type timeout: Sequence of C{int}
     291        @type timeout: C{None} or a sequence of C{int}
    289292        @param timeout: Number of seconds after which to reissue the query.
    290293        When the last timeout expires, the query is considered failed.
    291294
     
    336339        # Issue a query to a server.  Use the current timeout.  Add this
    337340        # function as a timeout errback in case another retry is required.
    338341        d = self._query(address, query, timeout[0], reason.value.id)
    339         d.addErrback(self._reissue, addressesLeft, addressesUsed, query, timeout)
     342        d.addErrback(
     343            self._reissue, addressesLeft, addressesUsed, query, timeout)
    340344        return d
    341345
    342346
    343     def queryTCP(self, queries, timeout = 10):
     347    def queryTCP(self, queries, timeout=10):
    344348        """
    345349        Make a number of DNS queries via TCP.
    346350
     
    378382        the answers section, the authority section, and the additional section.
    379383        """
    380384        if message.trunc:
    381             return self.queryTCP(message.queries).addCallback(self.filterAnswers)
     385            return self.queryTCP(
     386                message.queries).addCallback(self.filterAnswers)
    382387        if message.rCode != dns.OK:
    383             return failure.Failure(self.exceptionForCode(message.rCode)(message))
     388            return failure.Failure(
     389                self.exceptionForCode(message.rCode)(message))
    384390        return (message.answers, message.authority, message.additional)
    385391
    386392
     
    393399        will be re-used for this query as well.
    394400
    395401        @type name: C{str}
     402        @param name: DNS name to resolve.
     403
     404        @type cls: C{int}
     405        @param cls: The query class.
     406
    396407        @type type: C{int}
    397         @type cls: C{int}
    398 
    399         @return: A L{Deferred} which fires with a three-tuple giving the
    400             answer, authority, and additional sections of the response or with
    401             a L{Failure} if the response code is anything other than C{dns.OK}.
     408        @param type: The query type.
     409
     410        @type timeout: Sequence of C{int}
     411        @param timeout: Number of seconds after which to reissue the
     412        query.  When the last timeout expires, the query is considered
     413        failed.
     414
     415        @rtype: L{Deferred}
     416        @return: a L{Deferred} that fires with a 3-tuple of (results,
     417        authority, additional) lists, where each is a list of
     418        L{twisted.names.dns.RRHeader} instances or with a L{Failure}
     419        if the response code is anything other than C{dns.OK}.
    402420        """
    403421        key = (name, type, cls)
    404422        waiting = self._waiting.get(key)
    405423        if waiting is None:
    406424            self._waiting[key] = []
    407425            d = self.queryUDP([dns.Query(name, type, cls)], timeout)
     426
    408427            def cbResult(result):
    409428                for d in self._waiting.pop(key):
    410429                    d.callback(result)
    411430                return result
     431
    412432            d.addCallback(self.filterAnswers)
    413433            d.addBoth(cbResult)
    414434        else:
     
    417437        return d
    418438
    419439
    420     # This one doesn't ever belong on UDP
    421     def lookupZone(self, name, timeout = 10):
    422         """
    423         Perform an AXFR request. This is quite different from usual
    424         DNS requests. See http://cr.yp.to/djbdns/axfr-notes.html for
    425         more information.
    426         """
     440    def lookupZone(self, name, timeout=10):
    427441        address = self.pickServer()
    428442        if address is None:
    429443            return defer.fail(IOError('No domain name servers available'))
     
    431445        d = defer.Deferred()
    432446        controller = AXFRController(name, d)
    433447        factory = DNSClientFactory(controller, timeout)
    434         factory.noisy = False #stfu
     448        factory.noisy = False
    435449
    436450        connector = self._reactor.connectTCP(host, port, factory)
    437451        controller.timeoutCall = self._reactor.callLater(
     
    443457        connector.disconnect()
    444458        controller.timeoutCall = None
    445459        controller.deferred = None
    446         d.errback(error.TimeoutError("Zone lookup timed out after %d seconds" % (seconds,)))
     460        d.errback(
     461            error.TimeoutError(
     462                "Zone lookup timed out after %d seconds" % (seconds,)))
    447463
    448464    def _cbLookupZone(self, result, connector):
    449465        connector.disconnect()
     
    459475        self.soa = None
    460476        self.records = []
    461477
     478
    462479    def connectionMade(self, protocol):
    463480        # dig saids recursion-desired to 0, so I will too
    464481        message = dns.Message(protocol.pickID(), recDes=0)
     
    498515
    499516from twisted.internet.base import ThreadedResolver as _ThreadedResolverImpl
    500517
     518
    501519class ThreadedResolver(_ThreadedResolverImpl):
    502520    def __init__(self, reactor=None):
    503521        if reactor is None:
     
    509527            "instead.",
    510528            category=DeprecationWarning, stacklevel=2)
    511529
     530
     531
    512532class DNSClientFactory(protocol.ClientFactory):
    513     def __init__(self, controller, timeout = 10):
     533    def __init__(self, controller, timeout=10):
    514534        self.controller = controller
    515535        self.timeout = timeout
    516536
     
    532552
    533553    @type servers: C{list} of C{(str, int)} or C{None}
    534554
    535     @param servers: If not C{None}, interpreted as a list of domain name servers
    536     to attempt to use. Each server is a tuple of address in C{str} dotted-quad
    537     form and C{int} port number.
     555    @param servers: If not C{None}, interpreted as a list of domain
     556    name servers to attempt to use. Each server is a tuple of address
     557    in C{str} dotted-quad form and C{int} port number.
    538558
    539559    @type resolvconf: C{str} or C{None}
    540560    @param resolvconf: If not C{None}, on posix systems will be interpreted as
     
    567587    L = [hostResolver, cache.CacheResolver(), theResolver]
    568588    return resolve.ResolverChain(L)
    569589
     590
     591
    570592theResolver = None
     593
     594
    571595def getResolver():
    572596    """
    573597    Get a Resolver instance.
     
    585609            theResolver = createResolver(servers=[('127.0.0.1', 53)])
    586610    return theResolver
    587611
     612
     613
    588614def getHostByName(name, timeout=None, effort=10):
    589615    """
    590     Resolve a name to a valid ipv4 or ipv6 address.
    591 
    592     Will errback with C{DNSQueryTimeoutError} on a timeout, C{DomainError} or
    593     C{AuthoritativeDomainError} (or subclasses) on other errors.
    594 
    595     @type name: C{str}
    596     @param name: DNS name to resolve.
    597 
    598     @type timeout: Sequence of C{int}
    599     @param timeout: Number of seconds after which to reissue the query.
    600     When the last timeout expires, the query is considered failed.
    601 
    602     @type effort: C{int}
    603     @param effort: How many times CNAME and NS records to follow while
    604     resolving this name.
    605 
    606     @rtype: C{Deferred}
     616    @see: L{twisted.internet.interfaces.IResolverSimple.getHostByName}
    607617    """
    608618    return getResolver().getHostByName(name, timeout, effort)
    609619
     620
     621
    610622def lookupAddress(name, timeout=None):
    611623    """
    612     Perform an A record lookup.
    613 
    614     @type name: C{str}
    615     @param name: DNS name to resolve.
    616 
    617     @type timeout: Sequence of C{int}
    618     @param timeout: Number of seconds after which to reissue the query.
    619     When the last timeout expires, the query is considered failed.
    620 
    621     @rtype: C{Deferred}
     624    @see: L{twisted.internet.interfaces.IResolver.lookupAddress}
    622625    """
    623626    return getResolver().lookupAddress(name, timeout)
    624627
     628
     629
    625630def lookupIPV6Address(name, timeout=None):
    626631    """
    627     Perform an AAAA record lookup.
    628 
    629     @type name: C{str}
    630     @param name: DNS name to resolve.
    631 
    632     @type timeout: Sequence of C{int}
    633     @param timeout: Number of seconds after which to reissue the query.
    634     When the last timeout expires, the query is considered failed.
    635 
    636     @rtype: C{Deferred}
     632    @see: L{twisted.internet.interfaces.IResolver.lookupIPV6Address}
    637633    """
    638634    return getResolver().lookupIPV6Address(name, timeout)
    639635
     636
     637
    640638def lookupAddress6(name, timeout=None):
    641639    """
    642     Perform an A6 record lookup.
    643 
    644     @type name: C{str}
    645     @param name: DNS name to resolve.
    646 
    647     @type timeout: Sequence of C{int}
    648     @param timeout: Number of seconds after which to reissue the query.
    649     When the last timeout expires, the query is considered failed.
    650 
    651     @rtype: C{Deferred}
     640    @see: L{twisted.internet.interfaces.IResolver.lookupAddress6}
    652641    """
    653642    return getResolver().lookupAddress6(name, timeout)
    654643
     644
     645
    655646def lookupMailExchange(name, timeout=None):
    656647    """
    657     Perform an MX record lookup.
    658 
    659     @type name: C{str}
    660     @param name: DNS name to resolve.
    661 
    662     @type timeout: Sequence of C{int}
    663     @param timeout: Number of seconds after which to reissue the query.
    664     When the last timeout expires, the query is considered failed.
    665 
    666     @rtype: C{Deferred}
     648    @see: L{twisted.internet.interfaces.IResolver.lookupMailExchange}
    667649    """
    668650    return getResolver().lookupMailExchange(name, timeout)
    669651
     652
     653
    670654def lookupNameservers(name, timeout=None):
    671655    """
    672     Perform an NS record lookup.
    673 
    674     @type name: C{str}
    675     @param name: DNS name to resolve.
    676 
    677     @type timeout: Sequence of C{int}
    678     @param timeout: Number of seconds after which to reissue the query.
    679     When the last timeout expires, the query is considered failed.
    680 
    681     @rtype: C{Deferred}
     656    @see: L{twisted.internet.interfaces.IResolver.lookupNameservers}
    682657    """
    683658    return getResolver().lookupNameservers(name, timeout)
    684659
     660
     661
    685662def lookupCanonicalName(name, timeout=None):
    686663    """
    687     Perform a CNAME record lookup.
    688 
    689     @type name: C{str}
    690     @param name: DNS name to resolve.
    691 
    692     @type timeout: Sequence of C{int}
    693     @param timeout: Number of seconds after which to reissue the query.
    694     When the last timeout expires, the query is considered failed.
    695 
    696     @rtype: C{Deferred}
     664    @see: L{twisted.internet.interfaces.IResolver.lookupCanonicalName}
    697665    """
    698666    return getResolver().lookupCanonicalName(name, timeout)
    699667
     668
     669
    700670def lookupMailBox(name, timeout=None):
    701671    """
    702     Perform an MB record lookup.
    703 
    704     @type name: C{str}
    705     @param name: DNS name to resolve.
    706 
    707     @type timeout: Sequence of C{int}
    708     @param timeout: Number of seconds after which to reissue the query.
    709     When the last timeout expires, the query is considered failed.
    710 
    711     @rtype: C{Deferred}
     672    @see: L{twisted.internet.interfaces.IResolver.lookupMailBox}
    712673    """
    713674    return getResolver().lookupMailBox(name, timeout)
    714675
     676
     677
    715678def lookupMailGroup(name, timeout=None):
    716679    """
    717     Perform an MG record lookup.
    718 
    719     @type name: C{str}
    720     @param name: DNS name to resolve.
    721 
    722     @type timeout: Sequence of C{int}
    723     @param timeout: Number of seconds after which to reissue the query.
    724     When the last timeout expires, the query is considered failed.
    725 
    726     @rtype: C{Deferred}
     680    @see: L{twisted.internet.interfaces.IResolver.lookupMailGroup}
    727681    """
    728682    return getResolver().lookupMailGroup(name, timeout)
    729683
     684
     685
    730686def lookupMailRename(name, timeout=None):
    731687    """
    732     Perform an MR record lookup.
    733 
    734     @type name: C{str}
    735     @param name: DNS name to resolve.
    736 
    737     @type timeout: Sequence of C{int}
    738     @param timeout: Number of seconds after which to reissue the query.
    739     When the last timeout expires, the query is considered failed.
    740 
    741     @rtype: C{Deferred}
     688    @see: L{twisted.internet.interfaces.IResolver.lookupMailRename}
    742689    """
    743690    return getResolver().lookupMailRename(name, timeout)
    744691
     692
     693
    745694def lookupPointer(name, timeout=None):
    746695    """
    747     Perform a PTR record lookup.
    748 
    749     @type name: C{str}
    750     @param name: DNS name to resolve.
    751 
    752     @type timeout: Sequence of C{int}
    753     @param timeout: Number of seconds after which to reissue the query.
    754     When the last timeout expires, the query is considered failed.
    755 
    756     @rtype: C{Deferred}
     696    @see: L{twisted.internet.interfaces.IResolver.lookupPointer}
    757697    """
    758698    return getResolver().lookupPointer(name, timeout)
    759699
     700
     701
    760702def lookupAuthority(name, timeout=None):
    761703    """
    762     Perform an SOA record lookup.
    763 
    764     @type name: C{str}
    765     @param name: DNS name to resolve.
    766 
    767     @type timeout: Sequence of C{int}
    768     @param timeout: Number of seconds after which to reissue the query.
    769     When the last timeout expires, the query is considered failed.
    770 
    771     @rtype: C{Deferred}
     704    @see: L{twisted.internet.interfaces.IResolver.lookupAuthority}
    772705    """
    773706    return getResolver().lookupAuthority(name, timeout)
    774707
     708
     709
    775710def lookupNull(name, timeout=None):
    776711    """
    777     Perform a NULL record lookup.
    778 
    779     @type name: C{str}
    780     @param name: DNS name to resolve.
    781 
    782     @type timeout: Sequence of C{int}
    783     @param timeout: Number of seconds after which to reissue the query.
    784     When the last timeout expires, the query is considered failed.
    785 
    786     @rtype: C{Deferred}
     712    @see: L{twisted.internet.interfaces.IResolver.lookupNull}
    787713    """
    788714    return getResolver().lookupNull(name, timeout)
    789715
     716
     717
    790718def lookupWellKnownServices(name, timeout=None):
    791719    """
    792     Perform a WKS record lookup.
    793 
    794     @type name: C{str}
    795     @param name: DNS name to resolve.
    796 
    797     @type timeout: Sequence of C{int}
    798     @param timeout: Number of seconds after which to reissue the query.
    799     When the last timeout expires, the query is considered failed.
    800 
    801     @rtype: C{Deferred}
     720    @see: L{twisted.internet.interfaces.IResolver.lookupWellKnownServices}
    802721    """
    803722    return getResolver().lookupWellKnownServices(name, timeout)
    804723
     724
     725
    805726def lookupService(name, timeout=None):
    806727    """
    807     Perform an SRV record lookup.
    808 
    809     @type name: C{str}
    810     @param name: DNS name to resolve.
    811 
    812     @type timeout: Sequence of C{int}
    813     @param timeout: Number of seconds after which to reissue the query.
    814     When the last timeout expires, the query is considered failed.
    815 
    816     @rtype: C{Deferred}
     728    @see: L{twisted.internet.interfaces.IResolver.lookupService}
    817729    """
    818730    return getResolver().lookupService(name, timeout)
    819731
     732
     733
    820734def lookupHostInfo(name, timeout=None):
    821735    """
    822     Perform a HINFO record lookup.
    823 
    824     @type name: C{str}
    825     @param name: DNS name to resolve.
    826 
    827     @type timeout: Sequence of C{int}
    828     @param timeout: Number of seconds after which to reissue the query.
    829     When the last timeout expires, the query is considered failed.
    830 
    831     @rtype: C{Deferred}
     736    @see: L{twisted.internet.interfaces.IResolver.lookupHostInfo}
    832737    """
    833738    return getResolver().lookupHostInfo(name, timeout)
    834739
     740
     741
    835742def lookupMailboxInfo(name, timeout=None):
    836743    """
    837     Perform an MINFO record lookup.
    838 
    839     @type name: C{str}
    840     @param name: DNS name to resolve.
    841 
    842     @type timeout: Sequence of C{int}
    843     @param timeout: Number of seconds after which to reissue the query.
    844     When the last timeout expires, the query is considered failed.
    845 
    846     @rtype: C{Deferred}
     744    @see: L{twisted.internet.interfaces.IResolver.lookupMailboxInfo}
    847745    """
    848746    return getResolver().lookupMailboxInfo(name, timeout)
    849747
     748
     749
    850750def lookupText(name, timeout=None):
    851751    """
    852     Perform a TXT record lookup.
    853 
    854     @type name: C{str}
    855     @param name: DNS name to resolve.
    856 
    857     @type timeout: Sequence of C{int}
    858     @param timeout: Number of seconds after which to reissue the query.
    859     When the last timeout expires, the query is considered failed.
    860 
    861     @rtype: C{Deferred}
     752    @see: L{twisted.internet.interfaces.IResolver.lookupText}
    862753    """
    863754    return getResolver().lookupText(name, timeout)
    864755
     756
     757
    865758def lookupSenderPolicy(name, timeout=None):
    866759    """
    867     Perform a SPF record lookup.
    868 
    869     @type name: C{str}
    870     @param name: DNS name to resolve.
    871 
    872     @type timeout: Sequence of C{int}
    873     @param timeout: Number of seconds after which to reissue the query.
    874     When the last timeout expires, the query is considered failed.
    875 
    876     @rtype: C{Deferred}
     760    @see: L{twisted.internet.interfaces.IResolver.lookupSenderPolicy}
    877761    """
    878762    return getResolver().lookupSenderPolicy(name, timeout)
    879763
     764
     765
    880766def lookupResponsibility(name, timeout=None):
    881767    """
    882     Perform an RP record lookup.
    883 
    884     @type name: C{str}
    885     @param name: DNS name to resolve.
    886 
    887     @type timeout: Sequence of C{int}
    888     @param timeout: Number of seconds after which to reissue the query.
    889     When the last timeout expires, the query is considered failed.
    890 
    891     @rtype: C{Deferred}
     768    @see: L{twisted.internet.interfaces.IResolver.lookupResponsibility}
    892769    """
    893770    return getResolver().lookupResponsibility(name, timeout)
    894771
     772
     773
    895774def lookupAFSDatabase(name, timeout=None):
    896775    """
    897     Perform an AFSDB record lookup.
    898 
    899     @type name: C{str}
    900     @param name: DNS name to resolve.
    901 
    902     @type timeout: Sequence of C{int}
    903     @param timeout: Number of seconds after which to reissue the query.
    904     When the last timeout expires, the query is considered failed.
    905 
    906     @rtype: C{Deferred}
     776    @see: L{twisted.internet.interfaces.IResolver.lookupAFSDatabase}
    907777    """
    908778    return getResolver().lookupAFSDatabase(name, timeout)
    909779
     780
     781
    910782def lookupZone(name, timeout=None):
    911783    """
    912     Perform an AXFR record lookup.
    913 
    914     @type name: C{str}
    915     @param name: DNS name to resolve.
    916 
    917     @type timeout: C{int}
    918     @param timeout: When this timeout expires, the query is considered failed.
    919 
    920     @rtype: C{Deferred}
     784    @see: L{twisted.internet.interfaces.IResolver.lookupZone}
    921785    """
    922786    # XXX: timeout here is not a list of ints, it is a single int.
    923787    return getResolver().lookupZone(name, timeout)
    924788
     789
     790
    925791def lookupAllRecords(name, timeout=None):
    926792    """
    927     ALL_RECORD lookup.
    928 
    929     @type name: C{str}
    930     @param name: DNS name to resolve.
    931 
    932     @type timeout: Sequence of C{int}
    933     @param timeout: Number of seconds after which to reissue the query.
    934     When the last timeout expires, the query is considered failed.
    935 
    936     @rtype: C{Deferred}
     793    @see: L{twisted.internet.interfaces.IResolver.lookupAllRecords}
    937794    """
    938795    return getResolver().lookupAllRecords(name, timeout)
    939796
     
    941798
    942799def lookupNamingAuthorityPointer(name, timeout=None):
    943800    """
    944     NAPTR lookup.
    945 
    946     @type name: C{str}
    947     @param name: DNS name to resolve.
    948 
    949     @type timeout: Sequence of C{int}
    950     @param timeout: Number of seconds after which to reissue the query.
    951         When the last timeout expires, the query is considered failed.
    952 
    953     @rtype: C{Deferred}
     801    @see: L{twisted.internet.interfaces.IResolver.lookupNamingAuthorityPointer}
    954802    """
    955803    return getResolver().lookupNamingAuthorityPointer(name, timeout)
  • twisted/names/common.py

    === modified file 'twisted/names/common.py'
     
    1313from twisted.names.error import DNSNotImplementedError, DNSQueryRefusedError
    1414from twisted.names.error import DNSUnknownError
    1515
    16 from twisted.internet import defer, error
     16from twisted.internet import defer, error, interfaces
    1717from twisted.python import failure
    1818
     19from zope.interface import implements
     20
    1921EMPTY_RESULT = (), (), ()
    2022
     23
    2124class ResolverBase:
    2225    """
    2326    L{ResolverBase} is a base class for L{IResolver} implementations which
     
    2730    @cvar _errormap: A C{dict} mapping DNS protocol failure response codes
    2831        to exception classes which will be used to represent those failures.
    2932    """
     33
     34    implements(interfaces.IResolver)
     35
    3036    _errormap = {
    3137        dns.EFORMAT: DNSFormatError,
    3238        dns.ESERVER: DNSServerError,
     
    4147        for (k, v) in typeToMethod.items():
    4248            self.typeToMethod[k] = getattr(self, v)
    4349
    44 
    4550    def exceptionForCode(self, responseCode):
    4651        """
    4752        Convert a response code (one of the possible values of
     
    5156        """
    5257        return self._errormap.get(responseCode, DNSUnknownError)
    5358
    54 
    55     def query(self, query, timeout = None):
     59    def query(self, query, timeout=None):
    5660        try:
    5761            return self.typeToMethod[query.type](str(query.name), timeout)
    58         except KeyError, e:
    59             return defer.fail(failure.Failure(NotImplementedError(str(self.__class__) + " " + str(query.type))))
     62        except KeyError:
     63            return defer.fail(
     64                failure.Failure(
     65                    NotImplementedError(
     66                        str(self.__class__) + " " + str(query.type))))
    6067
    6168    def _lookup(self, name, cls, type, timeout):
    6269        return defer.fail(NotImplementedError("ResolverBase._lookup"))
    6370
    64     def lookupAddress(self, name, timeout = None):
    65         """
    66         @see: twisted.names.client.lookupAddress
    67         """
     71    def lookupAddress(self, name, timeout=None):
    6872        return self._lookup(name, dns.IN, dns.A, timeout)
    6973
    70     def lookupIPV6Address(self, name, timeout = None):
    71         """
    72         @see: twisted.names.client.lookupIPV6Address
    73         """
     74    def lookupIPV6Address(self, name, timeout=None):
    7475        return self._lookup(name, dns.IN, dns.AAAA, timeout)
    7576
    76     def lookupAddress6(self, name, timeout = None):
    77         """
    78         @see: twisted.names.client.lookupAddress6
    79         """
     77    def lookupAddress6(self, name, timeout=None):
    8078        return self._lookup(name, dns.IN, dns.A6, timeout)
    8179
    82     def lookupMailExchange(self, name, timeout = None):
    83         """
    84         @see: twisted.names.client.lookupMailExchange
    85         """
     80    def lookupMailExchange(self, name, timeout=None):
    8681        return self._lookup(name, dns.IN, dns.MX, timeout)
    8782
    88     def lookupNameservers(self, name, timeout = None):
    89         """
    90         @see: twisted.names.client.lookupNameservers
    91         """
     83    def lookupNameservers(self, name, timeout=None):
    9284        return self._lookup(name, dns.IN, dns.NS, timeout)
    9385
    94     def lookupCanonicalName(self, name, timeout = None):
    95         """
    96         @see: twisted.names.client.lookupCanonicalName
    97         """
     86    def lookupCanonicalName(self, name, timeout=None):
    9887        return self._lookup(name, dns.IN, dns.CNAME, timeout)
    9988
    100     def lookupMailBox(self, name, timeout = None):
    101         """
    102         @see: twisted.names.client.lookupMailBox
    103         """
     89    def lookupMailBox(self, name, timeout=None):
    10490        return self._lookup(name, dns.IN, dns.MB, timeout)
    10591
    106     def lookupMailGroup(self, name, timeout = None):
    107         """
    108         @see: twisted.names.client.lookupMailGroup
    109         """
     92    def lookupMailGroup(self, name, timeout=None):
    11093        return self._lookup(name, dns.IN, dns.MG, timeout)
    11194
    112     def lookupMailRename(self, name, timeout = None):
    113         """
    114         @see: twisted.names.client.lookupMailRename
    115         """
     95    def lookupMailRename(self, name, timeout=None):
    11696        return self._lookup(name, dns.IN, dns.MR, timeout)
    11797
    118     def lookupPointer(self, name, timeout = None):
    119         """
    120         @see: twisted.names.client.lookupPointer
    121         """
     98    def lookupPointer(self, name, timeout=None):
    12299        return self._lookup(name, dns.IN, dns.PTR, timeout)
    123100
    124     def lookupAuthority(self, name, timeout = None):
    125         """
    126         @see: twisted.names.client.lookupAuthority
    127         """
     101    def lookupAuthority(self, name, timeout=None):
    128102        return self._lookup(name, dns.IN, dns.SOA, timeout)
    129103
    130     def lookupNull(self, name, timeout = None):
    131         """
    132         @see: twisted.names.client.lookupNull
    133         """
     104    def lookupNull(self, name, timeout=None):
    134105        return self._lookup(name, dns.IN, dns.NULL, timeout)
    135106
    136     def lookupWellKnownServices(self, name, timeout = None):
    137         """
    138         @see: twisted.names.client.lookupWellKnownServices
    139         """
     107    def lookupWellKnownServices(self, name, timeout=None):
    140108        return self._lookup(name, dns.IN, dns.WKS, timeout)
    141109
    142     def lookupService(self, name, timeout = None):
    143         """
    144         @see: twisted.names.client.lookupService
    145         """
     110    def lookupService(self, name, timeout=None):
    146111        return self._lookup(name, dns.IN, dns.SRV, timeout)
    147112
    148     def lookupHostInfo(self, name, timeout = None):
    149         """
    150         @see: twisted.names.client.lookupHostInfo
    151         """
     113    def lookupHostInfo(self, name, timeout=None):
    152114        return self._lookup(name, dns.IN, dns.HINFO, timeout)
    153115
    154     def lookupMailboxInfo(self, name, timeout = None):
    155         """
    156         @see: twisted.names.client.lookupMailboxInfo
    157         """
     116    def lookupMailboxInfo(self, name, timeout=None):
    158117        return self._lookup(name, dns.IN, dns.MINFO, timeout)
    159118
    160     def lookupText(self, name, timeout = None):
    161         """
    162         @see: twisted.names.client.lookupText
    163         """
     119    def lookupText(self, name, timeout=None):
    164120        return self._lookup(name, dns.IN, dns.TXT, timeout)
    165121
    166     def lookupSenderPolicy(self, name, timeout = None):
    167         """
    168         @see: twisted.names.client.lookupSenderPolicy
    169         """
     122    def lookupSenderPolicy(self, name, timeout=None):
    170123        return self._lookup(name, dns.IN, dns.SPF, timeout)
    171124
    172     def lookupResponsibility(self, name, timeout = None):
    173         """
    174         @see: twisted.names.client.lookupResponsibility
    175         """
     125    def lookupResponsibility(self, name, timeout=None):
    176126        return self._lookup(name, dns.IN, dns.RP, timeout)
    177127
    178     def lookupAFSDatabase(self, name, timeout = None):
    179         """
    180         @see: twisted.names.client.lookupAFSDatabase
    181         """
     128    def lookupAFSDatabase(self, name, timeout=None):
    182129        return self._lookup(name, dns.IN, dns.AFSDB, timeout)
    183130
    184     def lookupZone(self, name, timeout = None):
    185         """
    186         @see: twisted.names.client.lookupZone
    187         """
     131    def lookupZone(self, name, timeout=None):
    188132        return self._lookup(name, dns.IN, dns.AXFR, timeout)
    189133
    190 
    191134    def lookupNamingAuthorityPointer(self, name, timeout=None):
    192         """
    193         @see: twisted.names.client.lookupNamingAuthorityPointer
    194         """
    195135        return self._lookup(name, dns.IN, dns.NAPTR, timeout)
    196136
    197 
    198     def lookupAllRecords(self, name, timeout = None):
    199         """
    200         @see: twisted.names.client.lookupAllRecords
    201         """
     137    def lookupAllRecords(self, name, timeout=None):
    202138        return self._lookup(name, dns.IN, dns.ALL_RECORDS, timeout)
    203139
    204     def getHostByName(self, name, timeout = None, effort = 10):
    205         """
    206         @see: twisted.names.client.getHostByName
    207         """
     140    def getHostByName(self, name, timeout=None, effort=10):
    208141        # XXX - respect timeout
    209142        return self.lookupAllRecords(name, timeout
    210143            ).addCallback(self._cbRecords, name, effort
  • twisted/names/resolve.py

    === modified file 'twisted/names/resolve.py'
     
    1111@author: Jp Calderone
    1212"""
    1313
    14 from twisted.internet import defer, interfaces
     14from twisted.internet import defer
    1515from twisted.names import dns
    16 from zope.interface import implements
    1716import common
    1817
     18
    1919class FailureHandler:
    2020    def __init__(self, resolver, query, timeout):
    2121        self.resolver = resolver
     
    3232class ResolverChain(common.ResolverBase):
    3333    """Lookup an address using multiple C{IResolver}s"""
    3434
    35     implements(interfaces.IResolver)
    36 
    37 
    3835    def __init__(self, resolvers):
    3936        common.ResolverBase.__init__(self)
    4037        self.resolvers = resolvers
     
    5047        return d
    5148
    5249
    53     def lookupAllRecords(self, name, timeout = None):
     50    def lookupAllRecords(self, name, timeout=None):
    5451        d = self.resolvers[0].lookupAllRecords(name, timeout)
    5552        for r in self.resolvers[1:]:
    5653            d = d.addErrback(