示例#1
0
 def __init__(self, thread_count=_ASYNC_WORKER_THREAD_COUNT, **reqargs):
     BaseClass.__init__(self)
     setattr(self, "reqargs", read_only_dict(reqargs))
     self._executor = concurrent.futures.ThreadPoolExecutor(thread_count)
示例#2
0
        self.response = response

    def __str__(self):
        return '{}(api={}, args={}, error_message={})'.format(self.__class__.__name__, self.api, self.args, repr(self.error_message))

    def __repr__(self):
        return '<{}>'.format(str(self))


def _exception_class_for_status(status, BaseClass=GoogleAPIError):

    def __init__(self, api, args, error_message, response):
        BaseClass.__init__(self, api, args, error_message, response)

    exception_name = _EXCEPTION_CLASS_NAME_FMT.format(snake_case_to_camel_case(status.value))
    ExceptionClass = type(exception_name, (BaseClass,), {'__init__' : __init__})

    return ExceptionClass


def _create_exceptions():
    for status in Status.errors():
        ExceptionClass = _exception_class_for_status(status)
        exceptions_by_status[status] = ExceptionClass
        globals()[ExceptionClass.__name__] = ExceptionClass

_create_exceptions()
exceptions_by_status = read_only_dict(exceptions_by_status)

__all__ = ['GoogleAPIError'] + [clazz.__name__ for clazz in exceptions_by_status.values()]