def __init__(self, sized_field, length, calc_func=lambda x: len(x) // 8, encoder=ENC_INT_DEFAULT, fuzzable=False, name=None):
        '''
        :param sized_field: (name of) field to be sized
        :param length: length of the size field (in bits)
        :param calc_func: function to calculate the value of the field. func(bits) -> int (default: length in bytes)
        :type encoder: :class:`~kitty.model.low_level.encoder.BitFieldEncoder`
        :param encoder: encoder for the field (default: ENC_INT_DEFAULT)
        :param fuzzable: is field fuzzable (default: False)
        :param name: (unique) name of the field (default: None)

        :examples:

            Calculate the size of a field/container in bits

            ::

                Container(name='sized chunk', fields=[
                    RandomBytes(name='chunk', value='1234', min_length=0, max_length=75),
                    Size(
                        name='size in bits',
                        sized_field='chunk',
                        length=32,
                        calc_func=lambda x: len(x)
                    )
                ])

            Calculate the size of a field/container in bytes, and add 5 to the result

            ::

                Container(name='sized chunk', fields=[
                    RandomBytes(name='chunk', value='1234', min_length=0, max_length=75),
                    Size(
                        name='size in bytes plus 5',
                        sized_field='chunk',
                        length=32,
                        calc_func=lambda x: len(x) // 8 + 5
                    )
                ])
        '''
        bit_field = BitField(value=0, length=length, encoder=encoder)
        super(Size, self).__init__(depends_on=sized_field, bit_field=bit_field, calc_func=calc_func, fuzzable=fuzzable, name=name)
        self.dependency_type = Calculated.LENGTH_BASED
        self._need_second_pass = True
def __init__ ( self , sized_field , length , calc_func = lambda x : len ( x ) // 8 , encoder = ENC_INT_DEFAULT , fuzzable = False , name = None ) : bit_field = BitField ( value = 0 , length = length , encoder = encoder ) super ( Size , self ) . __init__ ( depends_on = sized_field , bit_field = bit_field , calc_func = calc_func , fuzzable = fuzzable , name = name ) self . dependency_type = Calculated . LENGTH_BASED self . _need_second_pass = True
:param sized_field: (name of) field to be sized
        :param length: length of the size field (in bits)
        :param calc_func: function to calculate the value of the field. func(bits) -> int (default: length in bytes)
        :type encoder: :class:`~kitty.model.low_level.encoder.BitFieldEncoder`
        :param encoder: encoder for the field (default: ENC_INT_DEFAULT)
        :param fuzzable: is field fuzzable (default: False)
        :param name: (unique) name of the field (default: None)

        :examples:

            Calculate the size of a field/container in bits

            ::

                Container(name='sized chunk', fields=[
                    RandomBytes(name='chunk', value='1234', min_length=0, max_length=75),
                    Size(
                        name='size in bits',
                        sized_field='chunk',
                        length=32,
                        calc_func=lambda x: len(x)
                    )
                ])

            Calculate the size of a field/container in bytes, and add 5 to the result

            ::

                Container(name='sized chunk', fields=[
                    RandomBytes(name='chunk', value='1234', min_length=0, max_length=75),
                    Size(
                        name='size in bytes plus 5',
                        sized_field='chunk',
                        length=32,
                        calc_func=lambda x: len(x) // 8 + 5
                    )
                ])