dns :: name :: Name :: Class Name |
[hide private]
[frames] | no frames]

# Class Name

source code

    object --+
             |
            Name

A DNS name.

The dns.name.Name class represents a DNS name as a tuple of labels. Instances of the class are immutable.

Instance Methods | [hide private]
__init__(self, labels) Initialize a domain name from a list of labels. | source code
__setattr__(self, name, value) x.__setattr__('name', value) <==> x.name = value | source code
bool |
is_absolute(self) Is the most significant label of this name the root label? | source code
bool |
is_wild(self) Is this name wild? (I.e. | source code
int |
__hash__(self) Return a case-insensitive hash of the name. | source code
fullcompare(self, other) Compare two names, returning a 3-tuple (relation, order, nlabels). | source code
bool |
is_subdomain(self, other) Is self a subdomain of other? | source code
bool |
is_superdomain(self, other) Is self a superdomain of other? | source code
dns.name.Name object |
canonicalize(self) Return a name which is equal to the current name, but is in DNSSEC canonical form. | source code
__eq__(self, other) | source code
__ne__(self, other) | source code
__lt__(self, other) | source code
__le__(self, other) | source code
__ge__(self, other) | source code
__gt__(self, other) | source code
__repr__(self) repr(x) | source code
__str__(self) str(x) | source code
string |
to_text(self, omit_final_dot=False) Convert name to text format. | source code
string |
to_unicode(self, omit_final_dot=False) Convert name to Unicode text format. | source code
string |
to_digestable(self, origin=None) Convert name to a format suitable for digesting in hashes. | source code
to_wire(self, file=None, compress=None, origin=None) Convert name to wire format, possibly compressing it. | source code
int |
__len__(self) The length of the name (in labels). | source code
__getitem__(self, index) | source code
__getslice__(self, start, stop) | source code
__add__(self, other) | source code
__sub__(self, other) | source code
tuple |
split(self, depth) Split a name into a prefix and suffix at depth. | source code
dns.name.Name object |
concatenate(self, other) Return a new name which is the concatenation of self and other. | source code
dns.name.Name object |
relativize(self, origin) If self is a subdomain of origin, return a new name which is self relative to origin. | source code
dns.name.Name object |
derelativize(self, origin) If self is a relative name, return a new name which is the concatenation of self and origin. | source code
dns.name.Name object |
choose_relativity(self, origin=None, relativize=True) Return a name with the relativity desired by the caller. | source code
dns.name.Name object |
parent(self) Return the parent of the name. | source code
Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__sizeof__`, `__subclasshook__`

Instance Variables | [hide private]
| labels The tuple of labels in the name.

Properties | [hide private]
Inherited from `object`: `__class__`

Method Details | [hide private]

### __init__(self, labels) (Constructor) | source code
Initialize a domain name from a list of labels. Parameters: `labels` (any iterable whose values are strings) - the labels Overrides: object.__init__

### __setattr__(self, name, value) | source code
x.__setattr__('name', value) <==> x.name = value Overrides: object.__setattr__ (inherited documentation)

### is_wild(self) | source code
Is this name wild? (I.e. Is the least significant label '*'?) Returns: bool

### __hash__(self) (Hashing function) | source code
Return a case-insensitive hash of the name. Returns: int Overrides: object.__hash__

### fullcompare(self, other) | source code
Compare two names, returning a 3-tuple (relation, order, nlabels). relation describes the relation ship beween the names, and is one of: dns.name.NAMERELN_NONE, dns.name.NAMERELN_SUPERDOMAIN, dns.name.NAMERELN_SUBDOMAIN, dns.name.NAMERELN_EQUAL, or dns.name.NAMERELN_COMMONANCESTOR order is < 0 if self < other, > 0 if self > other, and == 0 if self == other. A relative name is always less than an absolute name. If both names have the same relativity, then the DNSSEC order relation is used to order them. nlabels is the number of significant labels that the two names have in common.

### is_subdomain(self, other) | source code
Is self a subdomain of other? The notion of subdomain includes equality. Returns: bool

### is_superdomain(self, other) | source code
Is self a superdomain of other? The notion of subdomain includes equality. Returns: bool

### __repr__(self) (Representation operator) | source code
repr(x) Overrides: object.__repr__ (inherited documentation)

### __str__(self) (Informal representation operator) | source code
str(x) Overrides: object.__str__ (inherited documentation)

### to_text(self, omit_final_dot=False) | source code
Convert name to text format. Parameters: `omit_final_dot` - If True, don't emit the final dot (denoting the root label) for absolute names. The default is False. Returns: string

### to_unicode(self, omit_final_dot=False) | source code
Convert name to Unicode text format. IDN ACE lables are converted to Unicode. Parameters: `omit_final_dot` - If True, don't emit the final dot (denoting the root label) for absolute names. The default is False. Returns: string

### to_digestable(self, origin=None) | source code
Convert name to a format suitable for digesting in hashes. The name is canonicalized and converted to uncompressed wire format. Parameters: `origin` (dns.name.Name object) - If the name is relative and origin is not None, then origin will be appended to it. Returns: string Raises: `NeedAbsoluteNameOrOrigin` - All names in wire format are absolute. If self is a relative name, then an origin must be supplied; if it is missing, then this exception is raised

### to_wire(self, file=None, compress=None, origin=None) | source code
Convert name to wire format, possibly compressing it. Parameters: `file` (file or None) - the file where the name is emitted (typically a cStringIO file). If None, a string containing the wire name will be returned. `compress` (dict) - The compression table. If None (the default) names will not be compressed. `origin` (dns.name.Name object) - If the name is relative and origin is not None, then origin will be appended to it. Raises: `NeedAbsoluteNameOrOrigin` - All names in wire format are absolute. If self is a relative name, then an origin must be supplied; if it is missing, then this exception is raised

### split(self, depth) | source code
Split a name into a prefix and suffix at depth. Parameters: `depth` (int) - the number of labels in the suffix Returns: tuple the tuple (prefix, suffix) Raises: `ValueError` - the depth was not >= 0 and <= the length of the name.

### concatenate(self, other) | source code
Return a new name which is the concatenation of self and other. Returns: dns.name.Name object Raises: `AbsoluteConcatenation` - self is absolute and other is not the empty name

### relativize(self, origin) | source code
If self is a subdomain of origin, return a new name which is self relative to origin. Otherwise return self. Returns: dns.name.Name object

### derelativize(self, origin) | source code
If self is a relative name, return a new name which is the concatenation of self and origin. Otherwise return self. Returns: dns.name.Name object

### choose_relativity(self, origin=None, relativize=True) | source code
Return a name with the relativity desired by the caller. If origin is None, then self is returned. Otherwise, if relativize is true the name is relativized, and if relativize is false the name is derelativized. Returns: dns.name.Name object

### parent(self) | source code
Return the parent of the name. Returns: dns.name.Name object Raises: `NoParent` - the name is either the root name or the empty name, and thus has no parent.

Instance Variable Details | [hide private]

### labels The tuple of labels in the name. Each label is a string of up to 63 octets.