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`.`python`.`_textattributes``

module documentation
(source)

This module provides some common functionality for the manipulation of formatting states.

Defining the mechanism by which text containing character attributes is constructed begins by subclassing `CharacterAttributesMixin`.

Defining how a single formatting state is to be serialized begins by subclassing `_FormattingStateMixin`.

Serializing a formatting structure is done with `flatten`.

See Also
`twisted.conch.insults.helper._FormattingState`
`twisted.conch.insults.text._CharacterAttributes`
`twisted.words.protocols.irc._FormattingState`
`twisted.words.protocols.irc._CharacterAttributes`

Class | `CharacterAttributesMixin` | Mixin for character attributes that implements a `__getattr__` method returning a new `_NormalAttr` instance when attempting to access a `'normal'` attribute; otherwise a new `_OtherAttr` instance is returned for names that appears in the ...
Class | `DefaultFormattingState` | A character attribute that does nothing, thus applying no attributes to text.
Function | `flatten` | Serialize a sequence of characters with attribute information
Class | `_Attribute` | A text attribute.
Class | `_BackgroundColorAttr` | Background color attribute.
Class | `_ColorAttr` | Generic color attribute.
Class | `_ColorAttribute` | A color text attribute.
Class | `_ForegroundColorAttr` | Foreground color attribute.
Class | `_FormattingStateMixin` | Mixin for the formatting state/attributes of a single character.
Class | `_NormalAttr` | A text attribute for normal text.
Class | `_OtherAttr` | A text attribute for text with formatting attributes.

def flatten(output, attrs, attributeRenderer='toVT102'): (source)

Serialize a sequence of characters with attribute information

The resulting string can be interpreted by compatible software so that the contained characters are displayed and, for those attributes which are supported by the software, the attributes expressed. The exact result of the serialization depends on the behavior of the method specified by attributeRenderer.

For example, if your terminal is VT102 compatible, you might run this for a colorful variation on the "hello world" theme:

        from twisted.conch.insults.text import flatten, attributes as A
        from twisted.conch.insults.helper import CharacterAttribute
        print(flatten(
            A.normal[A.bold[A.fg.red['He'], A.fg.green['ll'], A.fg.magenta['o'], ' ',
                            A.fg.yellow['Wo'], A.fg.blue['rl'], A.fg.cyan['d!']]],
            CharacterAttribute()))

Parameters
output | Object returned by accessing attributes of the module-level attributes object.
attrs | A formatting state instance used to determine how to serialize `output`.
attributeRenderer:`str` | Name of the method on attrs that should be called to render the attributes during serialization. Defaults to `'toVT102'`.
Returns
A string expressing the text and display attributes specified by `output`.