# Path: pandas_gbq/exceptions.py
# class AccessDenied(ValueError):
#     """
#     Raised when invalid credentials are provided, or tokens have expired.
#     """
# 
# class GenericGBQException(ValueError):
#     """
#     Raised when an unrecognized Google API Error occurs.
#     """
# 
# Path: pandas_gbq/features.py
# FEATURES = Features()


import copy
import concurrent.futures
import logging
import re
import time
import typing
import warnings
import numpy as np
    import pandas
import pandas_gbq.schema
import pandas_gbq.timestamp
    import tqdm  # noqa
        import pkg_resources  # noqa
        import db_dtypes  # noqa
        import pydata_google_auth  # noqa
        import google.auth  # noqa
        import google.api_core.client_info
        import pandas
        import pandas
    import db_dtypes
    import db_dtypes
    import pandas.api.types
from datetime import datetime
from typing import Any, Dict, Optional, Sequence, Union
from pandas_gbq.exceptions import (
    AccessDenied,
    GenericGBQException,
)
from pandas_gbq.features import FEATURES
        from google_auth_oauthlib.flow import InstalledAppFlow  # noqa
        from google.cloud import bigquery  # noqa
        from google.api_core.exceptions import GoogleAPIError
        from google.api_core.exceptions import ClientError
        from pandas_gbq import auth
        from google.cloud import bigquery
        from google.cloud import bigquery
        from google.auth.exceptions import RefreshError
        from google.cloud import bigquery
        from pandas_gbq import load
    from google.api_core import exceptions as google_exceptions
    from google.cloud import bigquery
    from pandas_gbq import schema
        from google.cloud.bigquery import DatasetReference
        from google.cloud.bigquery import TableReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import DatasetReference
        from google.cloud.bigquery import Table
        from google.cloud.bigquery import TableReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import DatasetReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import Dataset

    # http://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
    @staticmethod
    def sizeof_fmt(num, suffix="B"):
        fmt = "%3.1f %s%s"
        for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
            if abs(num) < 1024.0:
                return fmt % (num, unit, suffix)
            num /= 1024.0
        return fmt % (num, "Y", suffix)

    def get_client(self):

        client_info = google.api_core.client_info.ClientInfo(
            user_agent="pandas-{}".format(pandas.__version__)
        )
        return bigquery.Client(
            project=self.project_id,
            credentials=self.credentials,
            client_info=client_info,
        )

    @staticmethod
    def process_http_error(ex):
        # See `BigQuery Troubleshooting Errors
        # <https://cloud.google.com/bigquery/troubleshooting-errors>`__

        if "cancelled" in ex.message:
            raise QueryTimeout("Reason: {0}".format(ex))


# Path: pandas_gbq/exceptions.py
# class AccessDenied(ValueError):
#     """
#     Raised when invalid credentials are provided, or tokens have expired.
#     """
# 
# class GenericGBQException(ValueError):
#     """
#     Raised when an unrecognized Google API Error occurs.
#     """
# 
# Path: pandas_gbq/features.py
# FEATURES = Features()


# Path: pandas_gbq/gbq.py
import copy
import concurrent.futures
import logging
import re
import time
import typing
import warnings
import numpy as np
    import pandas
import pandas_gbq.schema
import pandas_gbq.timestamp
    import tqdm  # noqa
        import pkg_resources  # noqa
        import db_dtypes  # noqa
        import pydata_google_auth  # noqa
        import google.auth  # noqa
        import google.api_core.client_info
        import pandas
        import pandas
    import db_dtypes
    import db_dtypes
    import pandas.api.types
from datetime import datetime
from typing import Any, Dict, Optional, Sequence, Union
from pandas_gbq.exceptions import (
    AccessDenied,
    GenericGBQException,
)
from pandas_gbq.features import FEATURES
        from google_auth_oauthlib.flow import InstalledAppFlow  # noqa
        from google.cloud import bigquery  # noqa
        from google.api_core.exceptions import GoogleAPIError
        from google.api_core.exceptions import ClientError
        from pandas_gbq import auth
        from google.cloud import bigquery
        from google.cloud import bigquery
        from google.auth.exceptions import RefreshError
        from google.cloud import bigquery
        from pandas_gbq import load
    from google.api_core import exceptions as google_exceptions
    from google.cloud import bigquery
    from pandas_gbq import schema
        from google.cloud.bigquery import DatasetReference
        from google.cloud.bigquery import TableReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import DatasetReference
        from google.cloud.bigquery import Table
        from google.cloud.bigquery import TableReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import DatasetReference
        from google.api_core.exceptions import NotFound
        from google.cloud.bigquery import Dataset


    # http://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size
    @staticmethod
    def sizeof_fmt(num, suffix="B"):
        fmt = "%3.1f %s%s"
        for unit in ["", "K", "M", "G", "T", "P", "E", "Z"]:
            if abs(num) < 1024.0:
                return fmt % (num, unit, suffix)
            num /= 1024.0
        return fmt % (num, "Y", suffix)

    def get_client(self):

        client_info = google.api_core.client_info.ClientInfo(
            user_agent="pandas-{}".format(pandas.__version__)
        )
        return bigquery.Client(
            project=self.project_id,
            credentials=self.credentials,
            client_info=client_info,
        )

    @staticmethod
    def process_http_error(ex):
        # See `BigQuery Troubleshooting Errors
        # <https://cloud.google.com/bigquery/troubleshooting-errors>`__

        if "cancelled" in ex.message:
            raise QueryTimeout("Reason: {0}".format(ex))


        raise GenericGBQException("Reason: {0}".format(ex))