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
评论列表
文章目录