Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/hamcrest/core/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/hamcrest/core/base_description.py
from typing import Any, Iterable

from hamcrest.core.description import Description
from hamcrest.core.helpers.hasmethod import hasmethod
from hamcrest.core.helpers.ismock import ismock

__author__ = "Jon Reid"
__copyright__ = "Copyright 2011 hamcrest.org"
__license__ = "BSD, see License.txt"


class BaseDescription(Description):
    """Base class for all :py:class:`~hamcrest.core.description.Description`
    implementations.

    """

    def append_text(self, text: str) -> Description:
        self.append(text)
        return self

    def append_description_of(self, value: Any) -> Description:
        if not ismock(value) and hasmethod(value, "describe_to"):
            value.describe_to(self)
        elif isinstance(value, str):
            self.append(repr(value))
        else:
            description = str(value)
            if description[:1] == "<" and description[-1:] == ">":
                self.append(description)
            else:
                self.append("<")
                self.append(description)
                self.append(">")
        return self

    def append_list(self, start: str, separator: str, end: str, list: Iterable[Any]) -> Description:
        separate = False

        self.append(start)
        for item in list:
            if separate:
                self.append(separator)
            self.append_description_of(item)
            separate = True
        self.append(end)
        return self

    def append(self, string: str) -> None:
        """Append the string to the description."""
        raise NotImplementedError("append")

    def append_string_in_python_syntax(self, string: str) -> None:
        self.append("'")
        for ch in string:
            self.append(character_in_python_syntax(ch))
        self.append("'")


def character_in_python_syntax(ch: str) -> str:
    if ch == "'":
        return "'"
    elif ch == "\n":
        return "\\n"
    elif ch == "\r":
        return "\\r"
    elif ch == "\t":
        return "\\t"
    else:
        return ch

Spamworldpro Mini