Skip to content

API Reference

Install the package in editable mode so mkdocstrings can import the latest sources:

uv pip install -e .[docs]

Package Module

Public entry point for StringDataDeque (pure Python implementation).

PureStringDeque module-attribute

PureStringDeque = StringDeque

USING_PURE_PYTHON module-attribute

USING_PURE_PYTHON = True

__all__ module-attribute

__all__ = ['USING_PURE_PYTHON', 'CircularStringDeque', 'EncryptedStringDeque', 'PureStringDeque', 'RSAMessage', 'StringDataDeque', 'StringDeque', 'WORMStringDeque']

CircularStringDeque

Bases: StringDeque

A circular StringBuffer, overwrites once maxlen reached.

__init__

__init__(size: int, data: SequenceNonStr[Builtin_or_DefinesDunderStr] | None = None, sep: str = '') -> None
__init__(size: int, data: Builtin_or_DefinesDunderStr | None = None, sep: str = '') -> None
__init__(size, data=None, sep='')

Initialize CircularStringDeque with a limited size.

:param size: The maximum size of the data structure. :type size: int :param data: Initial data to populate the structure (optional). :type data: SequenceNonStr[Builtin_or_DefinesDunderStr] | Builtin_or_DefinesDunderStr | None :param sep: Separator for data elements when initializing (optional). :type sep: str

:return: None :rtype: None

EncryptedStringDeque

Bases: StringDataDeque[RSAMessage, Builtin_or_DefinesDunderStr]

Read once write many buffer, using RSA and AES.

:param public_key: The public key used for encryption. :type public_key: RSA.RsaKey :param data: The initial data to be stored in the deque. :type data: SequenceNonstrOfStr | str | None :param format_func: The function used to format the encrypted data. :type format_func: Callable[[RSAMessage], str] :param sep: The separator used when joining the strings. :type sep: str

__init__

__init__(public_key, data=None, format_func=__keep_encrypted, sep='')

Initialize the object.

:param public_key: The public key used for encryption. :type public_key: RSA.RsaKey

:param data: The data to be encrypted. Can be a single string or a list of strings. Defaults to None. :type data: Union[str, List[str], None]

:param format_func: The function used to format the encrypted data. Defaults to __keep_encrypted. :type format_func: Callable[[RSAMessage], str]

:param sep: The separator used to join multiple encrypted messages. Defaults to ''. :type sep: str

:return: None :rtype: None

__keep_encrypted staticmethod

__keep_encrypted(msg)

Keep the message encrypted.

:param msg: The encrypted message. :type msg: RSAMessage

:return: The encrypted message as a string. :rtype: str

decrypt staticmethod

decrypt(msg, private_key)

Decrypt a message using RSA encryption and AES decryption.

From https://www.pycryptodome.org/src/examples#encrypt-data-with-rsa.

:param msg: An RSAMessage object containing encrypted data. :type msg: RSAMessage

:param private_key: Private key used for decryption. :type private_key: RSA.RsaKey

:return: The decrypted message as a string. :rtype: str

RSAMessage

A dataclass representing an RSA message.

:param enc_session_key: The encrypted session key. :type enc_session_key: str | bytes :param nonce: The nonce value. :type nonce: str | bytes :param tag: The tag value. :type tag: str | bytes :param ciphertext: The encrypted ciphertext. :type ciphertext: str | bytes

__eq__

__eq__(value)

Check if the object is equal to another object.

:param value: The object to compare to. :type value: object

:return: True if the objects are equal, False otherwise. :rtype: bool

__init__

__init__(enc_session_key, nonce, tag, ciphertext)

Initialize the object.

:param enc_session_key: The encrypted session key. :type enc_session_key: str or bytes

:param nonce: The nonce value. :type nonce: str or bytes

:param tag: The tag value. :type tag: str or bytes

:param ciphertext: The encrypted ciphertext. :type ciphertext: str or bytes

:return: None :rtype: None

__str__

__str__()

Return the string representation of the object.

:return: The string representation of the object. :rtype: str

attribute_as_bytes

attribute_as_bytes(attribute_name)

Return the decoded attribute value as bytes.

:param attribute_name: Name of the attribute containing a Base64 encoded value. :type attribute_name: str

:return: The decoded attribute value as bytes. :rtype: bytes

StringDataDeque

Bases: Generic[DataType, ConvertibleToDataType]

A generic class representing a deque of data that can be formatted as a string.

:param convert_func: A function to convert data to a specific data type. :type convert_func: Callable[[ConvertibleToDataType], DataType] :param format_func: A function to format data as a string. :type format_func: Callable[[DataType], str] :param data: The data to be stored in the deque. :type data: SequenceNonStr[ConvertibleToDataType] | ConvertibleToDataType | None :param sep: The separator to join elements when converting to a string. defaults to '' :type sep: str

__add__

__add__(other)

Add the input data to the StringDataDeque.

:param other: Data to be added to the current object. :type other: ConvertibleToDataType

:return: Current object after adding the input data. :rtype: Self

__contains__

__contains__(key)

Return true if key is in the StringDataDeque or the string representation.

:param key: The key to check for in the data structure. :type key: DataType

:return: True if the key is found in the data structure, False otherwise. :rtype: bool

__format__

__format__(format_spec)

Format string with sep override.

:param format_spec: A string specifying the format. :type format_spec: str

:return: The formatted string. :rtype: str

__getitem__

__getitem__(key)

Get an item from the data using the specified key.

:param key: The key for retrieving the item from the data. :type key: SupportsIndex

:return: The item corresponding to the key in the data. :rtype: DataType

__iadd__

__iadd__(other)

Add another element to the data container in place.

:param other: Another element to add to the data container. :type other: ConvertibleToDataType

:return: The updated data container with the new element added. :rtype: Self

__init__

__init__(convert_func: Callable[[ConvertibleToDataType], DataType], format_func: Callable[[DataType], str], data: SequenceNonStr[ConvertibleToDataType] | None = None, sep: str = '') -> None
__init__(convert_func: Callable[[ConvertibleToDataType], DataType], format_func: Callable[[DataType], str], data: ConvertibleToDataType | None = None, sep: str = '') -> None
__init__(convert_func, format_func, data=None, sep='')

Initialize the StringDataDeque.

:param convert_func: A callable function that converts input data to a specific data type. :type convert_func: Callable[[ConvertibleToDataType], DataType]

:param format_func: A callable function that formats the data for display. :type format_func: Callable[[DataType], str]

:param data: Initial data to be processed. It can be a single element, a sequence of elements, or None. :type data: Union[ConvertibleToDataType, SequenceNonStr[ConvertibleToDataType], None]

:param sep: A separator to be used when displaying the data. :type sep: str

:return: None :rtype: None

__ior__

__ior__(other)

Update the object with the union of itself and another sequence.

:param other: A sequence of items that can be converted to the same data type as the object. :type other: SequenceNonStr[ConvertibleToDataType]

:return: The updated object after the union operation. :rtype: Self

__len__

__len__()

Return the length of the data stored in the StringDataDeque.

:return: The length of the data. :rtype: int

__radd__

__radd__(other)

Right add another value to the data container.

:param other: A value that can be converted to the underlying data type of the container. :type other: ConvertibleToDataType

:return: The modified container with the additional value added. :rtype: Self

__ror__

__ror__(other)

Right or.

Perform element-wise mapping of the input sequence using a conversion function and extend the internal data with the mapped values.

:param other: A sequence of elements to apply the conversion function to. :type other: Sequence

:return: Updated instance with the mapped values added to the internal data. :rtype: Self

__setitem__

__setitem__(key, value)

Set the value of a key in the data dictionary.

:param key: The key to set in the dictionary. :type key: SupportsIndex

:param value: The value to set for the given key. :type value: ConvertibleToDataType

:return: None :rtype: None

__str__

__str__()

Return string joined by sep.

:return: A string representation of the object. :rtype: str

clear

clear()

Clear the data stored in the object.

This method clears all elements in the internal data storage.

:return: None :rtype: None

draw

draw(index=-1)

Draw and remove an element from the object at the specified index.

:param index: The index of the element to be drawn and removed. Default is -1 (last element). :type index: int

:return: The drawn element from the object. :rtype: DataType

insert

insert(other: Sequence[T], /, pre_process_func: Callable[[T], ConvertibleToDataType] | None = None, skip_conversion: bool = False) -> Self
insert(other: T, /, pre_process_func: Callable[[T], ConvertibleToDataType] | None = None, skip_conversion: bool = False) -> Self
insert(other, /, pre_process_func=None, skip_conversion=False)

Insert item(s) into the stringDequeue.

:param other: Item(s) to insert. :param pre_process_func: Function that will preprocess the data, defaults to None :param skip_conversion: Flag to skip conversion of items, defaults to False :return: The StringDeque.

StringDeque

Bases: StringDataDeque[str, Builtin_or_DefinesDunderStr]

A class representing a StringDeque.

__init__

__init__(data: SequenceNonStr[Builtin_or_DefinesDunderStr] | None = None, sep: str = '') -> None
__init__(data: Builtin_or_DefinesDunderStr | None = None, sep: str = '') -> None
__init__(data=None, sep='')

Initialize the object with the given data and separator.

:param data: A sequence of non-string objects, a string, or None. :type data: Union[Sequence, str, None]

:param sep: Separator to use when joining the data elements. :type sep: str

:return: None :rtype: None

WORMStringDeque

Bases: StringDeque

A class representing a WORM (Write Once Read Many) String Deque.

This class extends StringDeque and implements WORM (Write Once Read Many) functionality. It does not allow modification of existing items once they are added.

The following methods are not implemented in WORMStringDeque and will raise

NotImplementedError:

  • setitem: Setting items using indexing is not allowed.
  • clear: Clearing all items from the deque is not allowed.
  • delitem: Deleting items from the deque is not allowed.

:raises NotImplementedError: When trying to perform unsupported operations on WORMStringDeque.

__delitem__

__delitem__(key)

Delete item from StringDeque.

:param key: Item to remove :raises NotImplementedError: Not Enabled on WORMStringDeque.

__init__

__init__(data: SequenceNonStr[Builtin_or_DefinesDunderStr] | None = None, sep: str = '') -> None
__init__(data: Builtin_or_DefinesDunderStr | None = None, sep: str = '') -> None
__init__(data=None, sep='')

Initialize the object with optional data and separator.

:param data: Optional data to initialize the object with. :type data: SequenceNonStr[Builtin_or_DefinesDunderStr] | Builtin_or_DefinesDunderStr | None

:param sep: Optional separator for the data. :type sep: str

:return: None :rtype: None

__setitem__

__setitem__(key, value)

Set the value for a key in the object.

:param key: The key to set the value for. :type key: SupportsIndex

:param value: The value to set for the key. :type value: Builtin_or_DefinesDunderStr

:return: None

:raise NotImplementedError: If the method is called and not implemented.

clear

clear()

Clear the object.

This method is not implemented and will raise a NotImplementedError with a message indicating that the method is not implemented.

:raises NotImplementedError: Method is not implemented in the current class.

Core Implementation

Holds StringDeque class as well as several implementations of it.

Builtin_or_DefinesDunderStr module-attribute

Builtin_or_DefinesDunderStr = Annotated[Printable, Is[_defines_str]]

ConvertibleToDataType module-attribute

ConvertibleToDataType = TypeVar('ConvertibleToDataType')

DataType module-attribute

DataType = TypeVar('DataType')

SequenceNonStr module-attribute

SequenceNonStr = Annotated[Sequence[T], ~IsInstance[str]]

T module-attribute

T = TypeVar('T')

current_func_name module-attribute

current_func_name = lambda n=0: co_name

nobeartype module-attribute

nobeartype = beartype(conf=BeartypeConf(strategy=O0))

CircularStringDeque

Bases: StringDeque

A circular StringBuffer, overwrites once maxlen reached.

__init__

__init__(size: int, data: SequenceNonStr[Builtin_or_DefinesDunderStr] | None = None, sep: str = '') -> None
__init__(size: int, data: Builtin_or_DefinesDunderStr | None = None, sep: str = '') -> None
__init__(size, data=None, sep='')

Initialize CircularStringDeque with a limited size.

:param size: The maximum size of the data structure. :type size: int :param data: Initial data to populate the structure (optional). :type data: SequenceNonStr[Builtin_or_DefinesDunderStr] | Builtin_or_DefinesDunderStr | None :param sep: Separator for data elements when initializing (optional). :type sep: str

:return: None :rtype: None

InMatch

Bases: str

A class representing a custom string type used for 'like' matching.

:param pattern: Pattern string to match against. :type pattern: str :return: True if pattern matches.

__eq__

__eq__(pattern)

Override eq method to perform a 'like' match.

:param pattern: Pattern string to match against. :return: True if pattern matches.

StringDataDeque

Bases: Generic[DataType, ConvertibleToDataType]

A generic class representing a deque of data that can be formatted as a string.

:param convert_func: A function to convert data to a specific data type. :type convert_func: Callable[[ConvertibleToDataType], DataType] :param format_func: A function to format data as a string. :type format_func: Callable[[DataType], str] :param data: The data to be stored in the deque. :type data: SequenceNonStr[ConvertibleToDataType] | ConvertibleToDataType | None :param sep: The separator to join elements when converting to a string. defaults to '' :type sep: str

__add__

__add__(other)

Add the input data to the StringDataDeque.

:param other: Data to be added to the current object. :type other: ConvertibleToDataType

:return: Current object after adding the input data. :rtype: Self

__contains__

__contains__(key)

Return true if key is in the StringDataDeque or the string representation.

:param key: The key to check for in the data structure. :type key: DataType

:return: True if the key is found in the data structure, False otherwise. :rtype: bool

__format__

__format__(format_spec)

Format string with sep override.

:param format_spec: A string specifying the format. :type format_spec: str

:return: The formatted string. :rtype: str

__getitem__

__getitem__(key)

Get an item from the data using the specified key.

:param key: The key for retrieving the item from the data. :type key: SupportsIndex

:return: The item corresponding to the key in the data. :rtype: DataType

__iadd__

__iadd__(other)

Add another element to the data container in place.

:param other: Another element to add to the data container. :type other: ConvertibleToDataType

:return: The updated data container with the new element added. :rtype: Self

__init__

__init__(convert_func: Callable[[ConvertibleToDataType], DataType], format_func: Callable[[DataType], str], data: SequenceNonStr[ConvertibleToDataType] | None = None, sep: str = '') -> None
__init__(convert_func: Callable[[ConvertibleToDataType], DataType], format_func: Callable[[DataType], str], data: ConvertibleToDataType | None = None, sep: str = '') -> None
__init__(convert_func, format_func, data=None, sep='')

Initialize the StringDataDeque.

:param convert_func: A callable function that converts input data to a specific data type. :type convert_func: Callable[[ConvertibleToDataType], DataType]

:param format_func: A callable function that formats the data for display. :type format_func: Callable[[DataType], str]

:param data: Initial data to be processed. It can be a single element, a sequence of elements, or None. :type data: Union[ConvertibleToDataType, SequenceNonStr[ConvertibleToDataType], None]

:param sep: A separator to be used when displaying the data. :type sep: str

:return: None :rtype: None

__ior__

__ior__(other)

Update the object with the union of itself and another sequence.

:param other: A sequence of items that can be converted to the same data type as the object. :type other: SequenceNonStr[ConvertibleToDataType]

:return: The updated object after the union operation. :rtype: Self

__len__

__len__()

Return the length of the data stored in the StringDataDeque.

:return: The length of the data. :rtype: int

__radd__

__radd__(other)

Right add another value to the data container.

:param other: A value that can be converted to the underlying data type of the container. :type other: ConvertibleToDataType

:return: The modified container with the additional value added. :rtype: Self

__ror__

__ror__(other)

Right or.

Perform element-wise mapping of the input sequence using a conversion function and extend the internal data with the mapped values.

:param other: A sequence of elements to apply the conversion function to. :type other: Sequence

:return: Updated instance with the mapped values added to the internal data. :rtype: Self

__setitem__

__setitem__(key, value)

Set the value of a key in the data dictionary.

:param key: The key to set in the dictionary. :type key: SupportsIndex

:param value: The value to set for the given key. :type value: ConvertibleToDataType

:return: None :rtype: None

__str__

__str__()

Return string joined by sep.

:return: A string representation of the object. :rtype: str

clear

clear()

Clear the data stored in the object.

This method clears all elements in the internal data storage.

:return: None :rtype: None

draw

draw(index=-1)

Draw and remove an element from the object at the specified index.

:param index: The index of the element to be drawn and removed. Default is -1 (last element). :type index: int

:return: The drawn element from the object. :rtype: DataType

insert

insert(other: Sequence[T], /, pre_process_func: Callable[[T], ConvertibleToDataType] | None = None, skip_conversion: bool = False) -> Self
insert(other: T, /, pre_process_func: Callable[[T], ConvertibleToDataType] | None = None, skip_conversion: bool = False) -> Self
insert(other, /, pre_process_func=None, skip_conversion=False)

Insert item(s) into the stringDequeue.

:param other: Item(s) to insert. :param pre_process_func: Function that will preprocess the data, defaults to None :param skip_conversion: Flag to skip conversion of items, defaults to False :return: The StringDeque.

StringDeque

Bases: StringDataDeque[str, Builtin_or_DefinesDunderStr]

A class representing a StringDeque.

__init__

__init__(data: SequenceNonStr[Builtin_or_DefinesDunderStr] | None = None, sep: str = '') -> None
__init__(data: Builtin_or_DefinesDunderStr | None = None, sep: str = '') -> None
__init__(data=None, sep='')

Initialize the object with the given data and separator.

:param data: A sequence of non-string objects, a string, or None. :type data: Union[Sequence, str, None]

:param sep: Separator to use when joining the data elements. :type sep: str

:return: None :rtype: None

WORMStringDeque

Bases: StringDeque

A class representing a WORM (Write Once Read Many) String Deque.

This class extends StringDeque and implements WORM (Write Once Read Many) functionality. It does not allow modification of existing items once they are added.

The following methods are not implemented in WORMStringDeque and will raise

NotImplementedError:

  • setitem: Setting items using indexing is not allowed.
  • clear: Clearing all items from the deque is not allowed.
  • delitem: Deleting items from the deque is not allowed.

:raises NotImplementedError: When trying to perform unsupported operations on WORMStringDeque.

__delitem__

__delitem__(key)

Delete item from StringDeque.

:param key: Item to remove :raises NotImplementedError: Not Enabled on WORMStringDeque.

__init__

__init__(data: SequenceNonStr[Builtin_or_DefinesDunderStr] | None = None, sep: str = '') -> None
__init__(data: Builtin_or_DefinesDunderStr | None = None, sep: str = '') -> None
__init__(data=None, sep='')

Initialize the object with optional data and separator.

:param data: Optional data to initialize the object with. :type data: SequenceNonStr[Builtin_or_DefinesDunderStr] | Builtin_or_DefinesDunderStr | None

:param sep: Optional separator for the data. :type sep: str

:return: None :rtype: None

__setitem__

__setitem__(key, value)

Set the value for a key in the object.

:param key: The key to set the value for. :type key: SupportsIndex

:param value: The value to set for the key. :type value: Builtin_or_DefinesDunderStr

:return: None

:raise NotImplementedError: If the method is called and not implemented.

clear

clear()

Clear the object.

This method is not implemented and will raise a NotImplementedError with a message indicating that the method is not implemented.

:raises NotImplementedError: Method is not implemented in the current class.

Optional Helpers

An example subclass of string deque.

Builtin_or_DefinesDunderStr = Annotated[Printable, Is[_defines_str]] module-attribute

SequenceNonstrOfStr = Annotated[Sequence[str], ~IsInstance[str]] module-attribute

Base64Encoded

Bases: str

A class representing a Base64 encoded string.

__get__(instance, owner)

Get the base64 encoded string.

:param instance: The instance to get the value for. :type instance: RSAMessage or None

:param owner: The owner type of the descriptor. :type owner: type

:return: The value of the descriptor for the instance. :rtype: str or Self

__init__(name_)

Initialize the base64encoded string.

__set__(instance, value)

Set the value and encode as base64.

:param instance: The instance of the class where the descriptor attribute is set. :type instance: RSAMessage

:param value: The value to be set, either a string or bytes. :type value: str or bytes

:return: None :rtype: None

get_decoded(instance)

Get value base64 decoded.

:param instance: An instance of RSAMessage. :type instance: RSAMessage

:return: The decoded message as bytes. :rtype: bytes

is_base64(sb) staticmethod

Check if the input string or bytes object is a valid Base64 encoded string.

:param sb: The input string or bytes object to be checked. :type sb: str or bytes

:return: True if the input is a valid Base64 encoded string, False otherwise. :rtype: bool

EncryptedStringDeque

Bases: StringDataDeque[RSAMessage, Builtin_or_DefinesDunderStr]

Read once write many buffer, using RSA and AES.

:param public_key: The public key used for encryption. :type public_key: RSA.RsaKey :param data: The initial data to be stored in the deque. :type data: SequenceNonstrOfStr | str | None :param format_func: The function used to format the encrypted data. :type format_func: Callable[[RSAMessage], str] :param sep: The separator used when joining the strings. :type sep: str

__init__(public_key, data=None, format_func=__keep_encrypted, sep='')

Initialize the object.

:param public_key: The public key used for encryption. :type public_key: RSA.RsaKey

:param data: The data to be encrypted. Can be a single string or a list of strings. Defaults to None. :type data: Union[str, List[str], None]

:param format_func: The function used to format the encrypted data. Defaults to __keep_encrypted. :type format_func: Callable[[RSAMessage], str]

:param sep: The separator used to join multiple encrypted messages. Defaults to ''. :type sep: str

:return: None :rtype: None

__keep_encrypted(msg) staticmethod

Keep the message encrypted.

:param msg: The encrypted message. :type msg: RSAMessage

:return: The encrypted message as a string. :rtype: str

decrypt(msg, private_key) staticmethod

Decrypt a message using RSA encryption and AES decryption.

From https://www.pycryptodome.org/src/examples#encrypt-data-with-rsa.

:param msg: An RSAMessage object containing encrypted data. :type msg: RSAMessage

:param private_key: Private key used for decryption. :type private_key: RSA.RsaKey

:return: The decrypted message as a string. :rtype: str

RSAMessage

A dataclass representing an RSA message.

:param enc_session_key: The encrypted session key. :type enc_session_key: str | bytes :param nonce: The nonce value. :type nonce: str | bytes :param tag: The tag value. :type tag: str | bytes :param ciphertext: The encrypted ciphertext. :type ciphertext: str | bytes

__eq__(value)

Check if the object is equal to another object.

:param value: The object to compare to. :type value: object

:return: True if the objects are equal, False otherwise. :rtype: bool

__init__(enc_session_key, nonce, tag, ciphertext)

Initialize the object.

:param enc_session_key: The encrypted session key. :type enc_session_key: str or bytes

:param nonce: The nonce value. :type nonce: str or bytes

:param tag: The tag value. :type tag: str or bytes

:param ciphertext: The encrypted ciphertext. :type ciphertext: str or bytes

:return: None :rtype: None

__str__()

Return the string representation of the object.

:return: The string representation of the object. :rtype: str

attribute_as_bytes(attribute_name)

Return the decoded attribute value as bytes.

:param attribute_name: Name of the attribute containing a Base64 encoded value. :type attribute_name: str

:return: The decoded attribute value as bytes. :rtype: bytes

StringDataDeque

Bases: Generic[DataType, ConvertibleToDataType]

A generic class representing a deque of data that can be formatted as a string.

:param convert_func: A function to convert data to a specific data type. :type convert_func: Callable[[ConvertibleToDataType], DataType] :param format_func: A function to format data as a string. :type format_func: Callable[[DataType], str] :param data: The data to be stored in the deque. :type data: SequenceNonStr[ConvertibleToDataType] | ConvertibleToDataType | None :param sep: The separator to join elements when converting to a string. defaults to '' :type sep: str

__add__(other)

Add the input data to the StringDataDeque.

:param other: Data to be added to the current object. :type other: ConvertibleToDataType

:return: Current object after adding the input data. :rtype: Self

__contains__(key)

Return true if key is in the StringDataDeque or the string representation.

:param key: The key to check for in the data structure. :type key: DataType

:return: True if the key is found in the data structure, False otherwise. :rtype: bool

__format__(format_spec)

Format string with sep override.

:param format_spec: A string specifying the format. :type format_spec: str

:return: The formatted string. :rtype: str

__getitem__(key)

Get an item from the data using the specified key.

:param key: The key for retrieving the item from the data. :type key: SupportsIndex

:return: The item corresponding to the key in the data. :rtype: DataType

__iadd__(other)

Add another element to the data container in place.

:param other: Another element to add to the data container. :type other: ConvertibleToDataType

:return: The updated data container with the new element added. :rtype: Self

__init__(convert_func, format_func, data=None, sep='')

__init__(convert_func: Callable[[ConvertibleToDataType], DataType], format_func: Callable[[DataType], str], data: SequenceNonStr[ConvertibleToDataType] | None = None, sep: str = '') -> None
__init__(convert_func: Callable[[ConvertibleToDataType], DataType], format_func: Callable[[DataType], str], data: ConvertibleToDataType | None = None, sep: str = '') -> None

Initialize the StringDataDeque.

:param convert_func: A callable function that converts input data to a specific data type. :type convert_func: Callable[[ConvertibleToDataType], DataType]

:param format_func: A callable function that formats the data for display. :type format_func: Callable[[DataType], str]

:param data: Initial data to be processed. It can be a single element, a sequence of elements, or None. :type data: Union[ConvertibleToDataType, SequenceNonStr[ConvertibleToDataType], None]

:param sep: A separator to be used when displaying the data. :type sep: str

:return: None :rtype: None

__ior__(other)

Update the object with the union of itself and another sequence.

:param other: A sequence of items that can be converted to the same data type as the object. :type other: SequenceNonStr[ConvertibleToDataType]

:return: The updated object after the union operation. :rtype: Self

__len__()

Return the length of the data stored in the StringDataDeque.

:return: The length of the data. :rtype: int

__radd__(other)

Right add another value to the data container.

:param other: A value that can be converted to the underlying data type of the container. :type other: ConvertibleToDataType

:return: The modified container with the additional value added. :rtype: Self

__ror__(other)

Right or.

Perform element-wise mapping of the input sequence using a conversion function and extend the internal data with the mapped values.

:param other: A sequence of elements to apply the conversion function to. :type other: Sequence

:return: Updated instance with the mapped values added to the internal data. :rtype: Self

__setitem__(key, value)

Set the value of a key in the data dictionary.

:param key: The key to set in the dictionary. :type key: SupportsIndex

:param value: The value to set for the given key. :type value: ConvertibleToDataType

:return: None :rtype: None

__str__()

Return string joined by sep.

:return: A string representation of the object. :rtype: str

clear()

Clear the data stored in the object.

This method clears all elements in the internal data storage.

:return: None :rtype: None

draw(index=-1)

Draw and remove an element from the object at the specified index.

:param index: The index of the element to be drawn and removed. Default is -1 (last element). :type index: int

:return: The drawn element from the object. :rtype: DataType

insert(other, /, pre_process_func=None, skip_conversion=False)

insert(other: Sequence[T], /, pre_process_func: Callable[[T], ConvertibleToDataType] | None = None, skip_conversion: bool = False) -> Self
insert(other: T, /, pre_process_func: Callable[[T], ConvertibleToDataType] | None = None, skip_conversion: bool = False) -> Self

Insert item(s) into the stringDequeue.

:param other: Item(s) to insert. :param pre_process_func: Function that will preprocess the data, defaults to None :param skip_conversion: Flag to skip conversion of items, defaults to False :return: The StringDeque.

Protocol Definitions

Holds Protocols and types.

Builtin_or_DefinesDunderStr = Annotated[Printable, Is[_defines_str]] module-attribute

SequenceNonStr = Annotated[Sequence[T], ~IsInstance[str]] module-attribute

SequenceNonstrOfStr = Annotated[Sequence[str], ~IsInstance[str]] module-attribute

T = TypeVar('T') module-attribute

Printable

Bases: Protocol

Used to denote class implements custom str method.

__str__()

Class should implement custom str method.

_defines_str(obj)

Check if an object defines a custom __str__ method.

:param obj: An object to check. :type obj: object

:return: True if the object defines a custom __str__ method, False otherwise. :rtype: bool