# Path: kitty/core/kassert.py
# def is_of_types(obj, the_types):
# def is_int(obj):
# def is_in(obj, it):
# def not_none(obj):


import sys
import six
from struct import pack
from binascii import hexlify
from base64 import b64encode
from bitstring import Bits, BitArray
from kitty.core import kassert, KittyException
:String Encoders: Used to encode fields that their value is of type *str* (String, Delimiter, RandomBytes etc.)

:BitField Encoders:
    Used to encode fields that inherit from BitField or contain BitField (UInt8, Size, Checksum etc.)
    Those encoders are also refferred to as Int Encoders.

:FloatingPoint Encoders:
    Used to encode fields that inherit from FloatingPoint field (Float, Double)
    Those encoders are also refferred to as Float Encoders
'''


def strToBytes(value):
    '''
    :type value: ``str``
    :param value: value to encode
    '''
    kassert.is_of_types(value, (bytes, bytearray, six.string_types))
    if isinstance(value, six.string_types):
        return bytes(bytearray([ord(x) for x in value]))
    elif isinstance(value, bytearray):
        return bytes(value)
    return value


def strToUtf8(value):
    '''
    :type value: ``str``
    :param value: value to encode
    '''

# Path: kitty/core/kassert.py
# def is_of_types(obj, the_types):
# def is_int(obj):
# def is_in(obj, it):
# def not_none(obj):


# Path: kitty/model/low_level/encoder.py
import sys
import six
from struct import pack
from binascii import hexlify
from base64 import b64encode
from bitstring import Bits, BitArray
from kitty.core import kassert, KittyException

:String Encoders: Used to encode fields that their value is of type *str* (String, Delimiter, RandomBytes etc.)

:BitField Encoders:
    Used to encode fields that inherit from BitField or contain BitField (UInt8, Size, Checksum etc.)
    Those encoders are also refferred to as Int Encoders.

:FloatingPoint Encoders:
    Used to encode fields that inherit from FloatingPoint field (Float, Double)
    Those encoders are also refferred to as Float Encoders
'''


def strToBytes(value):
    '''
    :type value: ``str``
    :param value: value to encode
    '''
    kassert.is_of_types(value, (bytes, bytearray, six.string_types))
    if isinstance(value, six.string_types):
        return bytes(bytearray([ord(x) for x in value]))
    elif isinstance(value, bytearray):
        return bytes(value)
    return value


def strToUtf8(value):
    '''
    :type value: ``str``
    :param value: value to encode
    '''

    kassert.is_of_types(value, str)