Exemple #1
0
def Padding(length, pattern=b"\x00", strict=False):
    r"""A padding field (adds bytes when building, discards bytes when parsing)

    :param length: the length of the field. the length can be either an integer,
                   or a function that takes the context as an argument and returns the length
    :param pattern: the padding pattern (character) to use. default is "\x00"
    :param strict: whether or not to raise an exception is the actual padding
                   pattern mismatches the desired pattern. default is False.
    """
    return PaddingAdapter(
        Field(None, length),
        pattern=pattern,
        strict=strict,
    )
Exemple #2
0
def Padding(length, pattern="\x00", strict=False):
    r"""a padding field (value is discarded)
    * length - the length of the field. the length can be either an integer,
      or a function that takes the context as an argument and returns the
      length
    * pattern - the padding pattern (character) to use. default is "\x00"
    * strict - whether or not to raise an exception is the actual padding
      pattern mismatches the desired pattern. default is False.
    """
    return PaddingAdapter(
        Field(None, length),
        pattern=pattern,
        strict=strict,
    )