data_structures.py 文件源码

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

项目:yt 作者: yt-project 项目源码 文件源码
def _is_valid(self, *args, **kwargs):
        """Checks whether the supplied file can be read by this frontend.
        """
        warn_h5py(args[0])
        try:
            f = h5.File(args[0], "r")
        except (IOError, OSError, ImportError):
            return False

        requirements = ["openPMD", "basePath", "meshesPath", "particlesPath"]
        attrs = list(f["/"].attrs.keys())
        for i in requirements:
            if i not in attrs:
                f.close()
                return False

        known_versions = [StrictVersion("1.0.0"),
                          StrictVersion("1.0.1")]
        if StrictVersion(f.attrs["openPMD"].decode()) in known_versions:
            f.close()
            return True
        else:
            f.close()
            return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号