def serializeFields(obj, order=None): """Turn an object's fields into a ';' and ',' seperated string. If order is None, obj should be a list, backslash escape each field and return a ';' separated string. """ fields = [] if order is None: fields = [backslashEscape(val) for val in obj] else: for field in order: escapedValueList = [backslashEscape(val) for val in toList(getattr(obj, field))] fields.append(','.join(escapedValueList)) return ';'.join(fields)
def serializeFields(obj, order=None): """Turn an object's fields into a ';' and ',' seperated string. If order is None, obj should be a list, backslash escape each field and return a ';' separated string. """ fields = [] if order is None: fields = [backslashEscape(val) for val in obj] else: for field in order: escapedValueList = [ backslashEscape(val) for val in toList(getattr(obj, field)) ] fields.append(','.join(escapedValueList)) return ';'.join(fields)
def encode(cls, line): """Backslash escape line.value.""" if not line.encoded: encoding = getattr(line, 'encoding_param', None) if encoding and encoding.upper() == cls.base64string: line.value = line.value.encode('base64').replace('\n', '') else: line.value = backslashEscape(line.value) line.encoded=True
def encode(cls, line): """Backslash escape line.value.""" if not line.encoded: encoding = getattr(line, 'encoding_param', None) if encoding and encoding.upper() == cls.base64string: line.value = line.value.encode('base64').replace('\n', '') else: line.value = backslashEscape(line.value) line.encoded = True