'Pretty print the file mode.'

def __unicode__(self):

    type_char = '-'
    mode = int(self)
    if stat.S_ISREG(mode):
        type_char = '-'
    elif stat.S_ISBLK(mode):
        type_char = 'b'
    elif stat.S_ISCHR(mode):
        type_char = 'c'
    elif stat.S_ISDIR(mode):
        type_char = 'd'
    elif stat.S_ISFIFO(mode):
        type_char = 'p'
    elif stat.S_ISLNK(mode):
        type_char = 'l'
    elif stat.S_ISSOCK(mode):
        type_char = 's'
    mode_template = ('rwx' * 3)
    bin_mode = bin(int(self))[2:]
    bin_mode = bin_mode[(-9):]
    bin_mode = (('0' * (9 - len(bin_mode))) + bin_mode)
    bits = []
    for i in range(len(mode_template)):
        if (bin_mode[i] == '1'):
            bit = mode_template[i]
        else:
            bit = '-'
        bits.append(bit)
    if (stat.S_ISUID & mode):
        bits[2] = 'S'
    if (stat.S_ISGID & mode):
        bits[5] = 'S'
    if (stat.S_ISVTX & mode):
        if (bits[8] == 'x'):
            bits[8] = 't'
        else:
            bits[8] = 'T'
    return (type_char + ''.join(bits))
