__init__.py 文件源码

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

项目:true_review 作者: lucadealfaro 项目源码 文件源码
def open_resource(self, name):
        """Open a resource from the zoneinfo subdir for reading.

        Uses the pkg_resources module if available and no standard file
        found at the calculated location.
        """
        name_parts = name.lstrip('/').split('/')
        for part in name_parts:
            if part == os.path.pardir or os.path.sep in part:
                raise ValueError('Bad path segment: %r' % part)
        filename = os.path.join(os.path.dirname(__file__),
                                'zoneinfo', *name_parts)
        if not os.path.exists(filename) and resource_stream is not None:
            # http://bugs.launchpad.net/bugs/383171 - we avoid using this
            # unless absolutely necessary to help when a broken version of
            # pkg_resources is installed.
            return resource_stream(__name__, 'zoneinfo/' + name)
        return open(filename, 'rb')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号