dissect.target.helpers.utils¶
Module Contents¶
Classes¶
Sortable and serializible string-based enum. |
|
Integer-based enum that allows for values other than defined members. |
Functions¶
Convert a single value or a list of values to a list. A value of |
|
Return name with all slashes '/', backslashes '' and spaces ' ' replaced by underscores '_'. |
|
A readinto implementation that uses |
|
Helper function for determining the correct timestamps for log files without year notation. |
Attributes¶
- dissect.target.helpers.utils.log¶
- dissect.target.helpers.utils.T¶
- dissect.target.helpers.utils.to_list(value: T | list[T] | None) list[T]¶
Convert a single value or a list of values to a list. A value of
Noneis converted to an empty list.- Parameters:
value – The value to convert.
- Returns:
A list of values.
- class dissect.target.helpers.utils.StrEnum¶
Bases:
str,enum.EnumSortable and serializible string-based enum.
- class dissect.target.helpers.utils.IntEnumMissing¶
Bases:
enum.IntEnumInteger-based enum that allows for values other than defined members.
- dissect.target.helpers.utils.parse_options_string(options: str) dict[str, str | bool]¶
- dissect.target.helpers.utils.SLUG_RE¶
- dissect.target.helpers.utils.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.
- dissect.target.helpers.utils.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.- Parameters:
buffer – The buffer we read the data into.
fh – The file-like object we use for reading.
- Returns:
the size in bytes that was read.
- dissect.target.helpers.utils.STRIP_RE¶
- dissect.target.helpers.utils.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
open_decompress().- Parameters:
path – A path to the log file to parse.
re_ts – Regex pattern for extracting the timestamp from each line.
ts_format – Time format specification for parsing the timestamp.
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.