:py:mod:`dissect.target.helpers.utils` ====================================== .. py:module:: dissect.target.helpers.utils Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: dissect.target.helpers.utils.StrEnum dissect.target.helpers.utils.IntEnumMissing Functions ~~~~~~~~~ .. autoapisummary:: :nosignatures: dissect.target.helpers.utils.findall dissect.target.helpers.utils.to_list 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.T dissect.target.helpers.utils.SLUG_RE dissect.target.helpers.utils.STRIP_RE .. py:data:: log .. py:function:: findall(buf: bytes, needle: bytes) -> collections.abc.Iterator[int] .. py:data:: T .. py:function:: to_list(value: T | list[T] | None) -> list[T] Convert a single value or a list of values to a list. A value of ``None`` is converted to an empty list. :param value: The value to convert. :returns: A list of values. .. py:class:: StrEnum Bases: :py:obj:`str`, :py:obj:`enum.Enum` Sortable and serializible string-based enum. .. py:class:: IntEnumMissing Bases: :py:obj:`enum.IntEnum` Integer-based enum that allows for values other than defined members. .. py:function:: parse_options_string(options: str) -> dict[str, 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: str | re.Pattern, ts_format: str, tzinfo: year_rollover_helper.tzinfo = timezone.utc) -> collections.abc.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.