exosip2ctypes.utils module

Some helper functions

exosip2ctypes.utils.to_bytes(s, encoding='utf-8')

Convert to bytes string.

Parameters:
  • s – String to convert.
  • encoding (str) – Encoding codec.
Returns:

bytes string, it’s bytes or str in Python 2.x, bytes in Python 3.x.

Return type:

bytes

  • In Python 2, convert s to bytes if it’s unicode.
  • In Python 2, return original s if it’s not unicode.
  • In Python 2, it equals to to_str().
  • In Python 3, convert s to bytes if it’s unicode or str.
  • In Python 3, return original s if it’s neither unicode nor str.
exosip2ctypes.utils.to_str(s, encoding='utf-8')

Convert to str string.

Parameters:
  • s – String to convert.
  • encoding (str) – Decoding codec.
Returns:

str string, it’s bytes in Python 2.x, unicode or str in Python 3.x.

Return type:

str

  • In Python 2, convert s to str if it’s unicode.
  • In Python 2, return original s if it’s not unicode.
  • In Python 2, it equals to to_bytes().
  • In Python 3, convert s to str if it’s bytes.
  • In Python 3, return original s if it’s not bytes.
  • In Python 3, it equals to to_unicode().
exosip2ctypes.utils.to_unicode(s, encoding='utf-8')

Convert to unicode string.

Parameters:
  • s – String to convert.
  • encoding (str) – Encoding codec.
Returns:

unicode string, it’s unicode in Python 2.x, str or unicode in Python 3.x.

Return type:

unicode

  • In Python 2, convert s to unicode if it’s str or bytes.
  • In Python 2, return original s if it’s neither str or bytes.
  • In Python 3, convert s to str or unicode if it’s bytes.
  • In Python 3, return original s if it’s not bytes.
  • In Python 3, it equals to to_str().
class exosip2ctypes.utils.LoggerMixin

Bases: object

Mixin Class provide a logger property

logger

logger instance.

Return type:logging.Logger

logger name format is ModuleName.ClassName