# Path: apitools/base/py/exceptions.py
# class Error(Exception):
# class TypecheckError(Error, TypeError):
# class NotFoundError(Error):
# class UserError(Error):
# class InvalidDataError(Error):
# class CommunicationError(Error):
# class HttpError(CommunicationError):
# class InvalidUserInputError(InvalidDataError):
# class InvalidDataFromServerError(InvalidDataError, CommunicationError):
# class BatchError(Error):
# class ConfigurationError(Error):
# class GeneratedClientError(Error):
# class ConfigurationValueError(UserError):
# class ResourceUnavailableError(Error):
# class CredentialsError(Error):
# class TransferError(CommunicationError):
# class TransferRetryError(TransferError):
# class TransferInvalidError(TransferError):
# class RequestError(CommunicationError):
# class RetryAfterError(HttpError):
# class BadStatusCodeError(HttpError):
# class NotYetImplementedError(GeneratedClientError):
# class StreamExhausted(Error):
#   def __init__(self, response, content, url):
#   def __str__(self):
#   def status_code(self):
#   def FromResponse(cls, http_response):
#   def __init__(self, response, content, url, retry_after):
#   def FromResponse(cls, http_response):
# 
# Path: apitools/gen/gen_client_lib.py
# def _StandardQueryParametersSchema(discovery_doc):
# def _ComputePaths(package, version, discovery_doc):
#   def __init__(self, discovery_doc, client_info, names, root_package, outdir,
#                base_package, generate_cli=False, use_proto2=False,
#                unelidable_request_methods=None):
#   def client_info(self):
#   def discovery_doc(self):
#   def names(self):
#   def outdir(self):
#   def use_proto2(self):
#   def _GetPrinter(self, out):
#   def WriteInit(self, out):
#   def WriteMessagesFile(self, out):
#   def WriteMessagesProtoFile(self, out):
#   def WriteServicesProtoFile(self, out):
#   def WriteClientLibrary(self, out):
#   def WriteCli(self, out):
# class DescriptorGenerator(object):
# 
# Path: apitools/gen/util.py
# class Error(Exception):
# class CommunicationError(Error):
# class Names(object):
# class ClientInfo(collections.namedtuple('ClientInfo', (
#     'package', 'scopes', 'version', 'client_id', 'client_secret',
#     'user_agent', 'client_class_name', 'url_version', 'api_key'))):
# class SimplePrettyPrinter(object):
# def _SortLengthFirst(a, b):
#   def __init__(self, strip_prefixes,
#                name_convention=None,
#                capitalize_enums=False):
#   def __FromCamel(name, separator='_'):
#   def __ToCamel(name, separator='_'):
#   def __ToLowerCamel(name, separator='_'):
#   def __StripName(self, name):
#   def CleanName(name):
#   def NormalizeRelativePath(path):
#   def NormalizeEnumName(self, enum_name):
#   def ClassName(self, name, separator='_'):
#   def MethodName(self, name, separator='_'):
#   def FieldName(self, name):
# def Chdir(dirname, create=True):
# def NormalizeVersion(version):
#   def Create(cls, discovery_doc,
#              scope_ls, client_id, client_secret, user_agent, names, api_key):
#   def default_directory(self):
#   def cli_rule_name(self):
#   def cli_file_name(self):
#   def client_rule_name(self):
#   def client_file_name(self):
#   def messages_rule_name(self):
#   def services_rule_name(self):
#   def messages_file_name(self):
#   def messages_proto_file_name(self):
#   def services_proto_file_name(self):
# def GetPackage(path):
# def CleanDescription(description):
#   def __init__(self, out):
#   def indent(self):
#   def CalculateWidth(self, max_width=78):
#   def Indent(self, indent='  '):
#   def CommentContext(self):
#   def __call__(self, *args):
# def NormalizeDiscoveryUrl(discovery_url):
# def FetchDiscoveryDoc(discovery_url, retries=5):
#   DEFAULT_NAME_CONVENTION = 'LOWER_CAMEL'
#   NAME_CONVENTIONS = ['LOWER_CAMEL', 'LOWER_WITH_UNDER', 'NONE']


import contextlib
import json
import logging
import os
import pkgutil
import sys
import gflags as flags
from google.apputils import appcommands
from apitools.base.py import exceptions
from apitools.gen import gen_client_lib
from apitools.gen import util
      with open(FLAGS.client_json) as client_json:
        f = json.loads(client_json.read())
        web = f.get('web', {})
        client_id = web.get('client_id')
        client_secret = web.get('client_secret')
    except IOError:
      raise exceptions.NotFoundError(
          'Failed to open client json file: %s' % FLAGS.client_json)
  else:
    client_id = FLAGS.client_id
    client_secret = FLAGS.client_secret

  if not client_id:
    logging.warning('No client ID supplied')
    client_id = ''

  if not client_secret:
    logging.warning('No client secret supplied')
    client_secret = ''

  client_info = util.ClientInfo.Create(
      discovery_doc, FLAGS.scope, client_id, client_secret,
      FLAGS.user_agent, names, FLAGS.api_key)
  outdir = os.path.expanduser(FLAGS.outdir) or client_info.default_directory
  if os.path.exists(outdir) and not FLAGS.overwrite:
    raise exceptions.ConfigurationValueError(
        'Output directory exists, pass --overwrite to replace '
        'the existing files.')

  root_package = FLAGS.root_package or util.GetPackage(outdir)  # pylint: disable=line-too-long

# Path: apitools/base/py/exceptions.py
# class Error(Exception):
# class TypecheckError(Error, TypeError):
# class NotFoundError(Error):
# class UserError(Error):
# class InvalidDataError(Error):
# class CommunicationError(Error):
# class HttpError(CommunicationError):
# class InvalidUserInputError(InvalidDataError):
# class InvalidDataFromServerError(InvalidDataError, CommunicationError):
# class BatchError(Error):
# class ConfigurationError(Error):
# class GeneratedClientError(Error):
# class ConfigurationValueError(UserError):
# class ResourceUnavailableError(Error):
# class CredentialsError(Error):
# class TransferError(CommunicationError):
# class TransferRetryError(TransferError):
# class TransferInvalidError(TransferError):
# class RequestError(CommunicationError):
# class RetryAfterError(HttpError):
# class BadStatusCodeError(HttpError):
# class NotYetImplementedError(GeneratedClientError):
# class StreamExhausted(Error):
#   def __init__(self, response, content, url):
#   def __str__(self):
#   def status_code(self):
#   def FromResponse(cls, http_response):
#   def __init__(self, response, content, url, retry_after):
#   def FromResponse(cls, http_response):
# 
# Path: apitools/gen/gen_client_lib.py
# def _StandardQueryParametersSchema(discovery_doc):
# def _ComputePaths(package, version, discovery_doc):
#   def __init__(self, discovery_doc, client_info, names, root_package, outdir,
#                base_package, generate_cli=False, use_proto2=False,
#                unelidable_request_methods=None):
#   def client_info(self):
#   def discovery_doc(self):
#   def names(self):
#   def outdir(self):
#   def use_proto2(self):
#   def _GetPrinter(self, out):
#   def WriteInit(self, out):
#   def WriteMessagesFile(self, out):
#   def WriteMessagesProtoFile(self, out):
#   def WriteServicesProtoFile(self, out):
#   def WriteClientLibrary(self, out):
#   def WriteCli(self, out):
# class DescriptorGenerator(object):
# 
# Path: apitools/gen/util.py
# class Error(Exception):
# class CommunicationError(Error):
# class Names(object):
# class ClientInfo(collections.namedtuple('ClientInfo', (
#     'package', 'scopes', 'version', 'client_id', 'client_secret',
#     'user_agent', 'client_class_name', 'url_version', 'api_key'))):
# class SimplePrettyPrinter(object):
# def _SortLengthFirst(a, b):
#   def __init__(self, strip_prefixes,
#                name_convention=None,
#                capitalize_enums=False):
#   def __FromCamel(name, separator='_'):
#   def __ToCamel(name, separator='_'):
#   def __ToLowerCamel(name, separator='_'):
#   def __StripName(self, name):
#   def CleanName(name):
#   def NormalizeRelativePath(path):
#   def NormalizeEnumName(self, enum_name):
#   def ClassName(self, name, separator='_'):
#   def MethodName(self, name, separator='_'):
#   def FieldName(self, name):
# def Chdir(dirname, create=True):
# def NormalizeVersion(version):
#   def Create(cls, discovery_doc,
#              scope_ls, client_id, client_secret, user_agent, names, api_key):
#   def default_directory(self):
#   def cli_rule_name(self):
#   def cli_file_name(self):
#   def client_rule_name(self):
#   def client_file_name(self):
#   def messages_rule_name(self):
#   def services_rule_name(self):
#   def messages_file_name(self):
#   def messages_proto_file_name(self):
#   def services_proto_file_name(self):
# def GetPackage(path):
# def CleanDescription(description):
#   def __init__(self, out):
#   def indent(self):
#   def CalculateWidth(self, max_width=78):
#   def Indent(self, indent='  '):
#   def CommentContext(self):
#   def __call__(self, *args):
# def NormalizeDiscoveryUrl(discovery_url):
# def FetchDiscoveryDoc(discovery_url, retries=5):
#   DEFAULT_NAME_CONVENTION = 'LOWER_CAMEL'
#   NAME_CONVENTIONS = ['LOWER_CAMEL', 'LOWER_WITH_UNDER', 'NONE']


# Path: apitools/gen/gen_client.py
import contextlib
import json
import logging
import os
import pkgutil
import sys
import gflags as flags
from google.apputils import appcommands
from apitools.base.py import exceptions
from apitools.gen import gen_client_lib
from apitools.gen import util

      with open(FLAGS.client_json) as client_json:
        f = json.loads(client_json.read())
        web = f.get('web', {})
        client_id = web.get('client_id')
        client_secret = web.get('client_secret')
    except IOError:
      raise exceptions.NotFoundError(
          'Failed to open client json file: %s' % FLAGS.client_json)
  else:
    client_id = FLAGS.client_id
    client_secret = FLAGS.client_secret

  if not client_id:
    logging.warning('No client ID supplied')
    client_id = ''

  if not client_secret:
    logging.warning('No client secret supplied')
    client_secret = ''

  client_info = util.ClientInfo.Create(
      discovery_doc, FLAGS.scope, client_id, client_secret,
      FLAGS.user_agent, names, FLAGS.api_key)
  outdir = os.path.expanduser(FLAGS.outdir) or client_info.default_directory
  if os.path.exists(outdir) and not FLAGS.overwrite:
    raise exceptions.ConfigurationValueError(
        'Output directory exists, pass --overwrite to replace '
        'the existing files.')

  root_package = FLAGS.root_package or util.GetPackage(outdir)  # pylint: disable=line-too-long

  return gen_client_lib.DescriptorGenerator(