"""Every receiver and every method that cuts or finds ``#`` is a report, whatever the receiver's type says.

``typed``, ``any_typed``, ``attribute_of_any``, ``sliced`` and ``marker`` hold one report each and ``found`` four:
a receiver typed ``str`` or ``Any``, an attribute of a value heki cannot tie to a class, a slice of the result, and
a separator given by a ``Final`` constant. ``near_miss`` asks where ``#`` stands without cutting there: no report.
"""

from typing import Any, Final

MARKER: Final = "#"


def typed(reference: str) -> str:
    return reference.split("#")[0]


def any_typed(reference: Any) -> str:
    return reference.partition("#")[0]


def attribute_of_any(holder: Any) -> str:
    return holder.ref.rpartition("#")[0]


def sliced(joined_path: str) -> str:
    return "".join(joined_path.partition("#")[::2])


def marker(path: str) -> str:
    return path.partition(MARKER)[2]


def found(reference: str) -> int:
    return reference.find("#") + reference.rfind("#") + reference.index("#") + reference.rindex("#")


def near_miss(reference: str) -> bool:
    return reference.startswith("#") or reference.endswith("#") or bool(reference.count("#"))
