main.py 文件源码

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

项目:rshell 作者: dhylands 项目源码 文件源码
def listdir_stat(dirname):
    """Returns a list of tuples for each file contained in the named
       directory, or None if the directory does not exist. Each tuple
       contains the filename, followed by the tuple returned by
       calling os.stat on the filename.
    """
    import os

    def stat(filename):
        rstat = os.stat(filename)
        if IS_UPY:
            # Micropython dates are relative to Jan 1, 2000. On the host, time
            # is relative to Jan 1, 1970.
            return rstat[:7] + tuple(tim + TIME_OFFSET for tim in rstat[7:])
        return tuple(rstat) # PGH formerly returned an os.stat_result instance

    try:
        files = os.listdir(dirname)
    except OSError:
        return None

    if dirname == '/':
        return list((file, stat('/' + file)) for file in files)

    return list((file, stat(dirname + '/' + file)) for file in files)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号