(input,errors='strict',filename='<data>',mode=0666)
return (outfile.getvalue(), len(input))
Encodes the object input and returns a tuple (output
        object, length consumed).

        errors defines the error handling to apply. It defaults to
        'strict' handling which is the only currently supported
        error handling for this codec.
Encodes the object input and returns a tuple (output
        object, length consumed).
Encodes the object input and returns a tuple ( output object length consumed ) .
def uu_encode(input,errors='strict',filename='<data>',mode=0666):

    """ Encodes the object input and returns a tuple (output
        object, length consumed).

        errors defines the error handling to apply. It defaults to
        'strict' handling which is the only currently supported
        error handling for this codec.

    """
    assert errors == 'strict'
    from cStringIO import StringIO
    from binascii import b2a_uu
    # using str() because of cStringIO's Unicode undesired Unicode behavior.
    infile = StringIO(str(input))
    outfile = StringIO()
    read = infile.read
    write = outfile.write

    # Encode
    write('begin %o %s\n' % (mode & 0777, filename))
    chunk = read(45)
    while chunk:
        write(b2a_uu(chunk))
        chunk = read(45)
    write(' \nend\n')

    return (outfile.getvalue(), len(input))
def uu_encode ( input , errors = 'strict' , filename = '<data>' , mode = 0666 ) : assert errors == 'strict' from cStringIO import StringIO from binascii import b2a_uu # using str() because of cStringIO's Unicode undesired Unicode behavior. infile = StringIO ( str ( input ) ) outfile = StringIO ( ) read = infile . read write = outfile . write # Encode write ( 'begin %o %s\n' % ( mode & 0777 , filename ) ) chunk = read ( 45 ) while chunk : write ( b2a_uu ( chunk ) ) chunk = read ( 45 ) write ( ' \nend\n' ) return ( outfile . getvalue ( ) , len ( input ) )