def METHOD_NAME(bits):
    """
    Translate a integer returned by stat.S_IMODE() to 4-digit permission
    string.
    :param bits: A integer returned by stat.S_IMODE(), like "511".
    :return : Translated 4-digit permission string, like "0777".
    """
    ubit = bits % 8
    bits //= 8
    gbit = bits % 8
    bits //= 8
    obit = bits % 8
    bits //= 8
    return "%s%s%s%s" % (bits, obit, gbit, ubit)