def as_binary(self, content, encoding='utf8'):
        '''Perform content encoding for binary write'''
        if hasattr(content, 'read'):
            return content.read()
        elif isinstance(content, six.text_type):
            return content.encode(encoding)
        else:
            return content
def as_binary ( self , content , encoding = 'utf8' ) : if hasattr ( content , 'read' ) : return content . read ( ) elif isinstance ( content , six . text_type ) : return content . encode ( encoding ) else : return content
Perform content encoding for binary write