This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Parse syslog message""" | |
import unittest | |
from io import BytesIO | |
from typing import Callable, TypeAlias, TypeVar | |
# Our tokens are bytes, so we use a memoryview as a stream of bytes. | |
Tokens: TypeAlias = BytesIO | |
# No error reporting, we just state that we failed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Parse syslog message""" | |
import unittest | |
from typing import Callable, TypeAlias, TypeVar | |
# Our tokens are bytes, so we use a memoryview as a stream of bytes. | |
Tokens: TypeAlias = memoryview | |
# No error reporting, we just state that we failed. | |
Failure = None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
trap cleanup SIGINT SIGTERM ERR EXIT | |
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P) | |
usage() { | |
cat <<EOF | |
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# taken from https://stackoverflow.com/questions/1035340/reading-binary-file-and-looping-over-each-byte | |
from pathlib import Path | |
from functools import partial | |
from io import DEFAULT_BUFFER_SIZE | |
def file_byte_iterator(path): | |
"""given a path, return an iterator over the file | |
that lazily loads the file | |
""" |