# Path: pytablewriter/sanitizer/_base.py
# def _preprocess(name: str) -> str:
#     return name.strip()


import re
from pathvalidate import validate_pathtype
from pathvalidate.error import ErrorReason, ValidationError
from ._base import _preprocess

    unicode_sheet_name = _preprocess(sheet_name)
    match = __RE_INVALID_EXCEL_SHEET_NAME.search(unicode_sheet_name)
    if match is not None:
        raise ValidationError(
            description="invalid char found in the sheet name: '{:s}'".format(
                re.escape(match.group())
            ),
            reason=ErrorReason.INVALID_CHARACTER,
        )


def sanitize_excel_sheet_name(sheet_name: str, replacement_text: str = "") -> str:
    """
    Replace invalid characters for an Excel sheet name within
    the ``sheet_name`` with the ``replacement_text``.
    Invalid characters are as follows:
    |invalid_excel_sheet_chars|.
    The ``sheet_name`` truncate to 31 characters
    (max sheet name length of Excel) from the head, if the length
    of the name is exceed 31 characters.

    :param str sheet_name: Excel sheet name to sanitize.
    :param str replacement_text: Replacement text.
    :return: A replacement string.
    :rtype: str
    :raises ValueError: If the ``sheet_name`` is an invalid sheet name.
    """

    try:

# Path: pytablewriter/sanitizer/_base.py
# def _preprocess(name: str) -> str:
#     return name.strip()


# Path: pytablewriter/sanitizer/_excel.py
import re
from pathvalidate import validate_pathtype
from pathvalidate.error import ErrorReason, ValidationError
from ._base import _preprocess


    unicode_sheet_name = _preprocess(sheet_name)
    match = __RE_INVALID_EXCEL_SHEET_NAME.search(unicode_sheet_name)
    if match is not None:
        raise ValidationError(
            description="invalid char found in the sheet name: '{:s}'".format(
                re.escape(match.group())
            ),
            reason=ErrorReason.INVALID_CHARACTER,
        )


def sanitize_excel_sheet_name(sheet_name: str, replacement_text: str = "") -> str:
    """
    Replace invalid characters for an Excel sheet name within
    the ``sheet_name`` with the ``replacement_text``.
    Invalid characters are as follows:
    |invalid_excel_sheet_chars|.
    The ``sheet_name`` truncate to 31 characters
    (max sheet name length of Excel) from the head, if the length
    of the name is exceed 31 characters.

    :param str sheet_name: Excel sheet name to sanitize.
    :param str replacement_text: Replacement text.
    :return: A replacement string.
    :rtype: str
    :raises ValueError: If the ``sheet_name`` is an invalid sheet name.
    """

    try:

        unicode_sheet_name = _preprocess(sheet_name)