diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2011-08-27 16:07:52 +0200 |
---|---|---|
committer | Jelmer Vernooij <jelmer@samba.org> | 2011-08-27 17:40:39 +0200 |
commit | 8bd71350abe48fdcfc0125e48fa97abdf31e1270 (patch) | |
tree | 2873d7fc77f9ec1992e24886a9feae80b48ffaef /lib/dnspython/dns/rdata.py | |
parent | bd01a8e79faa3d657f01529c063cd0e09d711880 (diff) | |
download | samba-8bd71350abe48fdcfc0125e48fa97abdf31e1270.tar.gz samba-8bd71350abe48fdcfc0125e48fa97abdf31e1270.tar.bz2 samba-8bd71350abe48fdcfc0125e48fa97abdf31e1270.zip |
dnspython: Update to latest upstream snapshot.
Autobuild-User: Jelmer Vernooij <jelmer@samba.org>
Autobuild-Date: Sat Aug 27 17:40:39 CEST 2011 on sn-devel-104
Diffstat (limited to 'lib/dnspython/dns/rdata.py')
-rw-r--r-- | lib/dnspython/dns/rdata.py | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/lib/dnspython/dns/rdata.py b/lib/dnspython/dns/rdata.py index 399677e984..350bf790b8 100644 --- a/lib/dnspython/dns/rdata.py +++ b/lib/dnspython/dns/rdata.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2007, 2009, 2010 Nominum, Inc. +# Copyright (C) 2001-2007, 2009-2011 Nominum, Inc. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose with or without fee is hereby granted, @@ -32,6 +32,7 @@ import dns.name import dns.rdataclass import dns.rdatatype import dns.tokenizer +import dns.wiredata _hex_chunksize = 32 @@ -256,6 +257,19 @@ class Rdata(object): def __hash__(self): return hash(self.to_digestable(dns.name.root)) + def _wire_cmp(self, other): + # A number of types compare rdata in wire form, so we provide + # the method here instead of duplicating it. + # + # We specifiy an arbitrary origin of '.' when doing the + # comparison, since the rdata may have relative names and we + # can't convert a relative name to wire without an origin. + b1 = cStringIO.StringIO() + self.to_wire(b1, None, dns.name.root) + b2 = cStringIO.StringIO() + other.to_wire(b2, None, dns.name.root) + return cmp(b1.getvalue(), b2.getvalue()) + def from_text(cls, rdclass, rdtype, tok, origin = None, relativize = True): """Build an rdata object from text format. @@ -399,12 +413,15 @@ def from_text(rdclass, rdtype, tok, origin = None, relativize = True): Once a class is chosen, its from_text() class method is called with the parameters to this function. + If I{tok} is a string, then a tokenizer is created and the string + is used as its input. + @param rdclass: The rdata class @type rdclass: int @param rdtype: The rdata type @type rdtype: int - @param tok: The tokenizer - @type tok: dns.tokenizer.Tokenizer + @param tok: The tokenizer or input text + @type tok: dns.tokenizer.Tokenizer or string @param origin: The origin to use for relative names @type origin: dns.name.Name @param relativize: Should names be relativized? @@ -456,5 +473,6 @@ def from_wire(rdclass, rdtype, wire, current, rdlen, origin = None): @type origin: dns.name.Name @rtype: dns.rdata.Rdata instance""" + wire = dns.wiredata.maybe_wrap(wire) cls = get_rdata_class(rdclass, rdtype) return cls.from_wire(rdclass, rdtype, wire, current, rdlen, origin) |