

def _get_all_tables(self, dataset_id, cache=False):
    'Retrieve a list of all tables for the dataset.\n\n        Parameters\n        ----------\n        dataset_id : str\n            The dataset to retrieve table names for\n        cache : bool, optional\n            To use cached value or not (default False). Timeout value equals\n            CACHE_TIMEOUT.\n\n        Returns\n        -------\n        dict\n            A ``dict`` of app ids mapped to their table names\n        '
    do_fetch = True
    if (cache and self.cache.get(dataset_id)):
        (time, result) = self.cache.get(dataset_id)
        if ((datetime.now() - time) < CACHE_TIMEOUT):
            do_fetch = False
    if do_fetch:
        result = self.bigquery.tables().list(projectId=self.project_id, datasetId=dataset_id).execute()
        page_token = result.get('nextPageToken')
        while page_token:
            res = self.bigquery.tables().list(projectId=self.project_id, datasetId=dataset_id, pageToken=page_token).execute()
            page_token = res.get('nextPageToken')
            result['tables'] += res.get('tables', [])
        self.cache[dataset_id] = (datetime.now(), result)
    return self._parse_table_list_response(result)

dataset/ETHPy150Open tylertreat/BigQuery-Python/bigquery/client.py BigQueryClient._get_all_tables/original