Go to the latest version of this document.
search in docstrings

Search bar offers the following options:

- Term presence. The below example searches for documents that must contain “foo”, might contain “bar” and must not contain “baz”: `+foo bar -baz`
- Wildcards. The below example searches for documents with words beginning with “foo”: `foo*`
- Search in specific fields. The following search matches all objects in "twisted.mail" that matches “search”: `+qname:twisted.mail.* +search`

  Possible fields: 'name', 'qname' (fully qualified name), 'docstring', and 'kind'. Last two fields are only applicable if "search in docstrings" is enabled.

- Fuzzy matches. The following search matches all documents that have a word within 1 edit distance of “foo”: `foo~1`

Results provided by Lunr.js

# ``twisted`.`mail`.`mail`.`DomainWithDefaultDict``

class documentation

`class DomainWithDefaultDict: (source)`

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
klass | Undocumented
keys:iterable of `bytes` | Domain names to serve as keys in the new dictionary.
value:`None` or `IDomain` provider | A domain object to serve as the value for all new keys in the dictionary.
Returns
`DomainWithDefaultDict` | A 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:`bytes` | A domain name.
Returns
`bool` | `True` 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:`bytes` | A 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:`bytes` | A domain name.
Returns
`IDomain` provider or `None` | A domain object.

def __init__(self, domains, default): (source)

Parameters
domains:`dict` of `bytes` -> `IDomain` provider | A mapping of domain name to domain object.
default:`IDomain` provider | The default domain.

def __iter__(self): (source)

Return an iterator over the domain names in this dictionary.

Returns
iterator over `bytes` | An iterator over the domain names.

def __len__(self): (source)

Return the number of domains in this dictionary.

Returns
`int` | The number of domains in this dictionary.

def __repr__(self): (source)

Build an "official" string representation of this dictionary.

Returns
`bytes` | A 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:`bytes` | A domain name.
value:`IDomain` provider | A domain object.

def __str__(self): (source)

Build an informal string representation of this dictionary.

Returns
`bytes` | A string containing the mapping of domain names to domain objects.

def clear(self): (source)

Remove all items from this dictionary.

Returns
`None` | None.

def copy(self): (source)

Make a copy of this dictionary.

Returns
`DomainWithDefaultDict` | A copy of this dictionary.

def get(self, key, default=None): (source)

Look up a domain name in this dictionary.

Parameters
key:`bytes` | A domain name.
default:`IDomain` provider or `None` | A domain object to be returned if the domain name is not in this dictionary.
Returns
`IDomain` provider or `None` | The 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:`bytes` | A domain name.
Returns
`bool` | `True` 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 `None` | Domain 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 `None` | An 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 `bytes` | An 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 `None` | An iterator over the domain objects.

def keys(self): (source)

Return a list of all domain names in this dictionary.

Returns
`list` of `bytes` | The 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 `None` | A domain name/domain object pair.
Raises
`KeyError` | When 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:`bytes` | A domain name.
default:`IDomain` provider | A domain object.
Returns
`IDomain` provider or `None` | The domain object associated with the domain name.

def setDefaultDomain(self, domain): (source)

Set the default domain.

Parameters
domain:`IDomain` provider | The 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` -> `None` | Another dictionary of domain name/domain object pairs.
Returns
`None` | None.

def values(self): (source)

Return a list of all domain objects in this dictionary.

Returns
`list` of `IDomain` provider or `None` | The domain objects in this dictionary.

default = (source)

See `__init__`

domains = (source)

See `__init__`