:py:mod:`dissect.target.helpers.utils` ====================================== .. py:module:: dissect.target.helpers.utils Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.target.helpers.utils.StrEnum Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.target.helpers.utils.list_to_frozen_set dissect.target.helpers.utils.parse_path_uri dissect.target.helpers.utils.parse_options_string dissect.target.helpers.utils.slugify dissect.target.helpers.utils.readinto dissect.target.helpers.utils.year_rollover_helper Attributes ~~~~~~~~~~ .. autoapisummary:: dissect.target.helpers.utils.log dissect.target.helpers.utils.SLUG_RE dissect.target.helpers.utils.STRIP_RE .. py:data:: log .. py:class:: StrEnum Bases: :py:obj:`str`, :py:obj:`enum.Enum` Sortable and serializible string-based enum .. py:function:: list_to_frozen_set(function: Callable) -> Callable .. py:function:: parse_path_uri(path: pathlib.Path) -> tuple[Optional[str], Optional[str], Optional[str]] .. py:function:: parse_options_string(options: str) -> dict[str, Union[str, bool]] .. py:data:: SLUG_RE .. py:function:: slugify(name: str) -> str Return name with all slashes '/', backslashes '\' and spaces ' ' replaced by underscores '_'. This is useful to turn a name into something that can be used as filename. .. py:function:: readinto(buffer: bytearray, fh: BinaryIO) -> int A readinto implementation that uses ``read()``. Reads the length of the buffer from ``fh``, and fills the buffer with said data. :param buffer: The buffer we read the data into. :param fh: The file-like object we use for reading. :returns: the size in bytes that was read. .. py:data:: STRIP_RE .. py:function:: year_rollover_helper(path: pathlib.Path, re_ts: Union[str, re.Pattern], ts_format: str, tzinfo: year_rollover_helper.tzinfo = timezone.utc) -> Iterator[tuple[datetime.datetime, str]] Helper function for determining the correct timestamps for log files without year notation. Supports compressed files by using :func:`open_decompress`. :param path: A path to the log file to parse. :param re_ts: Regex pattern for extracting the timestamp from each line. :param ts_format: Time format specification for parsing the timestamp. :param tzinfo: The timezone to use when parsing timestamps. :returns: An iterator of tuples of the parsed timestamp and the lines of the file in reverse.