class documentation

class DomainWithDefaultDict: (source)

Constructor: DomainWithDefaultDict(domains, default)

View In Hierarchy

A simulated dictionary for mapping domain names to domain objects with a default value for non-existing keys.

Class Method fromkeys Create a new DomainWithDefaultDict with the specified keys.
Method __contains__ Test for the presence of a domain name in this dictionary.
Method __delitem__ Delete the entry for a domain name in this dictionary.
Method __getitem__ Look up a domain name and, if it is present, return the domain object associated with it. Otherwise return the default domain.
Method __init__ No summary
Method __iter__ Return an iterator over the domain names in this dictionary.
Method __len__ Return the number of domains in this dictionary.
Method __repr__ Build an "official" string representation of this dictionary.
Method __setitem__ Associate a domain object with a domain name in this dictionary.
Method __str__ Build an informal string representation of this dictionary.
Method clear Remove all items from this dictionary.
Method copy Make a copy of this dictionary.
Method get Look up a domain name in this dictionary.
Method has_key Test for the presence of a domain name in this dictionary.
Method items Return a list of all domain name/domain object pairs in this dictionary.
Method iteritems Return an iterator over the domain name/domain object pairs in the dictionary.
Method iterkeys Return an iterator over the domain names in this dictionary.
Method itervalues Return an iterator over the domain objects in this dictionary.
Method keys Return a list of all domain names in this dictionary.
Method popitem Remove a random domain name/domain object pair from this dictionary and return it as a tuple.
Method setdefault Return the domain object associated with the domain name if it is present in this dictionary. Otherwise, set the value for the domain name to the default and return that value.
Method setDefaultDomain Set the default domain.
Method update Update this dictionary with domain name/domain object pairs from another dictionary.
Method values Return a list of all domain objects in this dictionary.
Instance Variable default See __init__
Instance Variable domains See __init__
@classmethod
def fromkeys(klass, keys, value=None): (source)

Create a new DomainWithDefaultDict with the specified keys.

Parameters
klassUndocumented
keys:iterable of bytesDomain names to serve as keys in the new dictionary.
value:None or IDomain providerA domain object to serve as the value for all new keys in the dictionary.
Returns
DomainWithDefaultDictA new dictionary.
def __contains__(self, name): (source)

Test for the presence of a domain name in this dictionary.

This always returns True because a default value will be returned if the name doesn't exist in this dictionary.

Parameters
name:bytesA domain name.
Returns
boolTrue to indicate that the domain name is in this dictionary.
def __delitem__(self, name): (source)

Delete the entry for a domain name in this dictionary.

Parameters
name:bytesA domain name.
def __getitem__(self, name): (source)

Look up a domain name and, if it is present, return the domain object associated with it. Otherwise return the default domain.

Parameters
name:bytesA domain name.
Returns
IDomain provider or NoneA domain object.
def __init__(self, domains, default): (source)
Parameters
domains:dict of bytes -> IDomain providerA mapping of domain name to domain object.
default:IDomain providerThe default domain.
def __iter__(self): (source)

Return an iterator over the domain names in this dictionary.

Returns
iterator over bytesAn iterator over the domain names.
def __len__(self): (source)

Return the number of domains in this dictionary.

Returns
intThe number of domains in this dictionary.
def __repr__(self) -> str: (source)

Build an "official" string representation of this dictionary.

Returns
bytesA pseudo-executable string describing the underlying domain mapping of this object.
def __setitem__(self, name, value): (source)

Associate a domain object with a domain name in this dictionary.

Parameters
name:bytesA domain name.
value:IDomain providerA domain object.
def __str__(self) -> str: (source)

Build an informal string representation of this dictionary.

Returns
bytesA string containing the mapping of domain names to domain objects.
def clear(self): (source)

Remove all items from this dictionary.

Returns
NoneNone.
def copy(self): (source)

Make a copy of this dictionary.

Returns
DomainWithDefaultDictA copy of this dictionary.
def get(self, key, default=None): (source)

Look up a domain name in this dictionary.

Parameters
key:bytesA domain name.
default:IDomain provider or NoneA domain object to be returned if the domain name is not in this dictionary.
Returns
IDomain provider or NoneThe domain object associated with the domain name if it is in this dictionary. Otherwise, the default value.
def has_key(self, name): (source)

Test for the presence of a domain name in this dictionary.

This always returns True because a default value will be returned if the name doesn't exist in this dictionary.

Parameters
name:bytesA domain name.
Returns
boolTrue to indicate that the domain name is in this dictionary.
def items(self): (source)

Return a list of all domain name/domain object pairs in this dictionary.

Returns
list of 2-tuple of (1) bytes, (2) IDomain provider or NoneDomain name/domain object pairs in this dictionary.
def iteritems(self): (source)

Return an iterator over the domain name/domain object pairs in the dictionary.

Using the returned iterator while adding or deleting entries from the dictionary may result in a RuntimeError or failing to iterate over all the domain name/domain object pairs.

Returns
iterator over 2-tuple of (1) bytes, (2) IDomain provider or NoneAn iterator over the domain name/domain object pairs.
def iterkeys(self): (source)

Return an iterator over the domain names in this dictionary.

Using the returned iterator while adding or deleting entries from the dictionary may result in a RuntimeError or failing to iterate over all the domain names.

Returns
iterator over bytesAn iterator over the domain names.
def itervalues(self): (source)

Return an iterator over the domain objects in this dictionary.

Using the returned iterator while adding or deleting entries from the dictionary may result in a RuntimeError or failing to iterate over all the domain objects.

Returns
iterator over IDomain provider or NoneAn iterator over the domain objects.
def keys(self): (source)

Return a list of all domain names in this dictionary.

Returns
list of bytesThe domain names in this dictionary.
def popitem(self): (source)

Remove a random domain name/domain object pair from this dictionary and return it as a tuple.

Returns
2-tuple of (1) bytes, (2) IDomain provider or NoneA domain name/domain object pair.
Raises
KeyErrorWhen this dictionary is empty.
def setdefault(self, key, default): (source)

Return the domain object associated with the domain name if it is present in this dictionary. Otherwise, set the value for the domain name to the default and return that value.

Parameters
key:bytesA domain name.
default:IDomain providerA domain object.
Returns
IDomain provider or NoneThe domain object associated with the domain name.
def setDefaultDomain(self, domain): (source)

Set the default domain.

Parameters
domain:IDomain providerThe default domain.
def update(self, other): (source)

Update this dictionary with domain name/domain object pairs from another dictionary.

When this dictionary contains a domain name which is in the other dictionary, its value will be overwritten.

Parameters
other:dict of bytes -> IDomain provider and/or bytes -> NoneAnother dictionary of domain name/domain object pairs.
Returns
NoneNone.
def values(self): (source)

Return a list of all domain objects in this dictionary.

Returns
list of IDomain provider or NoneThe domain objects in this dictionary.