def inputToString(bytes_input_var, encoding): if isinstance(bytes_input_var, constants.STRING): return bytes_input_var elif isinstance(bytes_input_var, constants.BYTES): return bytes_input_var.decode(encoding) elif bytes_input_var is None: return '' else: raise ConversionError('Cannot convert to STRING type')
def inputToBytes(string_input_var, encoding): if isinstance(string_input_var, constants.BYTES): return string_input_var elif isinstance(string_input_var, constants.STRING): return string_input_var.encode(encoding) elif string_input_var is None: return b'' else: raise ConversionError('Cannot convert to BYTES type')