utils.py 文件源码

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

项目:gwrappy 作者: danielpoonwj 项目源码 文件源码
def __init__(self, resp, description=None):
        """
        Wrapper for Bigquery table resources, mainly for calculating/parsing job statistics into human readable formats for logging.

        :param resp: Dictionary representation of a table resource.
        :type resp: dictionary
        :param description: Optional string descriptor for table.
        """

        assert isinstance(resp, dict)
        assert resp['kind'].split('#')[-1] == 'table'

        self.resp = resp
        if description is not None:
            self.description = description.strip().title()

        try:
            setattr(self, 'row_count', int(self.resp['numRows']))
        except (KeyError, TypeError):
            pass

        try:
            setattr(self, 'size', humanize.naturalsize(int(self.resp['numBytes'])))
        except (KeyError, TypeError):
            pass
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号