gae.py 文件源码

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

项目:flow-dashboard 作者: onejgordon 项目源码 文件源码
def open_resource(self, name):
        """Opens a resource from the zoneinfo subdir for reading."""
        # Import nested here so we can run setup.py without GAE.
        from google.appengine.api import memcache
        from pytz import OLSON_VERSION

        name_parts = name.lstrip('/').split('/')
        if os.path.pardir in name_parts:
            raise ValueError('Bad path segment: %r' % os.path.pardir)

        cache_key = 'pytz.zoneinfo.%s.%s' % (OLSON_VERSION, name)
        zonedata = memcache.get(cache_key)
        if zonedata is None:
            zonedata = get_zoneinfo().read('zoneinfo/' + '/'.join(name_parts))
            memcache.add(cache_key, zonedata)
            log.info('Added timezone to memcache: %s' % cache_key)
        else:
            log.info('Loaded timezone from memcache: %s' % cache_key)

        return StringIO(zonedata)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号