filesys.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:ZServer 作者: zopefoundation 项目源码 文件源码
def unix_longify(file, stat_info):
        # for now, only pay attention to the lower bits
    mode = ('%o' % stat_info[stat.ST_MODE])[-3:]
    mode = string.join(map(lambda x: mode_table[x], mode), '')
    if stat.S_ISDIR(stat_info[stat.ST_MODE]):
        dirchar = 'd'
    else:
        dirchar = '-'
    date = ls_date(int(time.time()), stat_info[stat.ST_MTIME])
    user = str(stat_info[stat.ST_UID]).replace(' ', '_')
    group = str(stat_info[stat.ST_GID]).replace(' ', '_')
    if user == 'System_Processes':
        user = 'Sysproc'
    if group == 'System_Processes':
        group = 'Sysproc'

    return '%s%s %3d %-8s %-8s %8d %s %s' % (
        dirchar,
        mode,
        stat_info[stat.ST_NLINK],
        user,
        group,
        stat_info[stat.ST_SIZE],
        date,
        file
    )

# Emulate the unix 'ls' command's date field.
# it has two formats - if the date is more than 180
# days in the past, then it's like this:
# Oct 19  1995
# otherwise, it looks like this:
# Oct 19 17:33
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号