core.py 文件源码

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

项目:s3fs 作者: dask 项目源码 文件源码
def info(self, path, refresh=False, **kwargs):
        """ Detail on the specific file pointed to by path.

        Gets details only for a specific key, directories/buckets cannot be
        used with info.
        """
        parent = path.rsplit('/', 1)[0]
        files = self._lsdir(parent, refresh=refresh)
        files = [f for f in files if f['Key'] == path and f['StorageClass'] not
                 in ['DIRECTORY', 'BUCKET']]
        if len(files) == 1:
            return files[0]
        else:
            try:
                bucket, key = split_path(path)
                out = self._call_s3(self.s3.head_object,
                                    kwargs, Bucket=bucket, Key=key, **self.req_kw)
                out = {'ETag': out['ETag'], 'Key': '/'.join([bucket, key]),
                       'LastModified': out['LastModified'],
                       'Size': out['ContentLength'], 'StorageClass': "STANDARD"}
                return out
            except (ClientError, ParamValidationError):
                raise FileNotFoundError(path)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号