# Path: apitools/gen/extended_descriptor.py
# class ExtendedEnumValueDescriptor(messages.Message):
# class ExtendedEnumDescriptor(messages.Message):
#   class JsonEnumMapping(messages.Message):
# class ExtendedFieldDescriptor(messages.Message):
# class ExtendedMessageDescriptor(messages.Message):
#   class JsonFieldMapping(messages.Message):
# class ExtendedFileDescriptor(messages.Message):
# class ProtoPrinter(six.with_metaclass(abc.ABCMeta, object)):
# class _Proto2Printer(ProtoPrinter):
# class _ProtoRpcPrinter(ProtoPrinter):
# def _WriteFile(file_descriptor, package, version, proto_printer):
# def WriteMessagesFile(file_descriptor, package, version, printer):
# def WritePythonFile(file_descriptor, package, version, printer):
# def PrintIndentedDescriptions(printer, ls, name, prefix=''):
# def _FetchCustomMappings(descriptor_ls):
# def _FormatCustomJsonMapping(mapping_type, mapping, descriptor):
# def _EmptyMessage(message_type):
#   def PrintPreamble(self, package, version, file_descriptor):
#   def PrintEnum(self, enum_type):
#   def PrintMessage(self, message_type):
#   def __init__(self, printer):
#   def __PrintEnumCommentLines(self, enum_type):
#   def __PrintEnumValueCommentLines(self, enum_value):
#   def PrintEnum(self, enum_type):
#   def PrintPreamble(self, package, version, file_descriptor):
#   def __PrintMessageCommentLines(self, message_type):
#   def __PrintFieldDescription(self, description):
#   def __PrintFields(self, fields):
#   def PrintMessage(self, message_type):
#   def PrintCustomJsonMapping(self, mapping_lines):
#   def __init__(self, printer):
#   def __PrintClassSeparator(self):
#   def __PrintEnumDocstringLines(self, enum_type):
#   def PrintEnum(self, enum_type):
#   def __PrintAdditionalImports(self, imports):
#   def PrintPreamble(self, package, version, file_descriptor):
#   def __PrintMessageDocstringLines(self, message_type):
#   def PrintMessage(self, message_type):
#   def PrintCustomJsonMapping(self, mapping):
# def _PrintEnums(proto_printer, enum_types):
# def _PrintMessages(proto_printer, message_list):
# def _PrintFields(fields, printer):
# _MESSAGE_FIELD_MAP = {
#     message_types.DateTimeMessage.definition_name(): message_types.DateTimeField,
# }


import logging
import textwrap
from protorpc import descriptor
from protorpc import messages
from apitools.gen import extended_descriptor
  def __PrintGetClient(self, printer):
    printer('def GetClientFromFlags():')
    with printer.Indent():
      printer('"""Return a client object, configured from flags."""')
      printer('log_request = FLAGS.log_request or FLAGS.log_request_response')
      printer('log_response = FLAGS.log_response or FLAGS.log_request_response')
      printer('api_endpoint = apitools_base.NormalizeApiEndpoint('
              'FLAGS.api_endpoint)')
      printer("additional_http_headers = dict(x.split('=', 1) for x in "
              "FLAGS.add_header)")
      printer('try:')
      with printer.Indent():
        printer('client = client_lib.%s(', self.__client_info.client_class_name)
        with printer.Indent(indent='    '):
          printer('api_endpoint, log_request=log_request,')
          printer('log_response=log_response,')
          printer('additional_http_headers=additional_http_headers)')
      printer('except apitools_base.CredentialsError as e:')
      with printer.Indent():
        printer("print 'Error creating credentials: %%s' %% e")
        printer('sys.exit(1)')
      printer('return client')
    printer()
    printer()

  def __PrintCommandDocstring(self, printer, command_info):
    with printer.CommentContext():
      for line in textwrap.wrap('"""%s' % command_info.description,
                                printer.CalculateWidth()):
        printer(line)

# Path: apitools/gen/extended_descriptor.py
# class ExtendedEnumValueDescriptor(messages.Message):
# class ExtendedEnumDescriptor(messages.Message):
#   class JsonEnumMapping(messages.Message):
# class ExtendedFieldDescriptor(messages.Message):
# class ExtendedMessageDescriptor(messages.Message):
#   class JsonFieldMapping(messages.Message):
# class ExtendedFileDescriptor(messages.Message):
# class ProtoPrinter(six.with_metaclass(abc.ABCMeta, object)):
# class _Proto2Printer(ProtoPrinter):
# class _ProtoRpcPrinter(ProtoPrinter):
# def _WriteFile(file_descriptor, package, version, proto_printer):
# def WriteMessagesFile(file_descriptor, package, version, printer):
# def WritePythonFile(file_descriptor, package, version, printer):
# def PrintIndentedDescriptions(printer, ls, name, prefix=''):
# def _FetchCustomMappings(descriptor_ls):
# def _FormatCustomJsonMapping(mapping_type, mapping, descriptor):
# def _EmptyMessage(message_type):
#   def PrintPreamble(self, package, version, file_descriptor):
#   def PrintEnum(self, enum_type):
#   def PrintMessage(self, message_type):
#   def __init__(self, printer):
#   def __PrintEnumCommentLines(self, enum_type):
#   def __PrintEnumValueCommentLines(self, enum_value):
#   def PrintEnum(self, enum_type):
#   def PrintPreamble(self, package, version, file_descriptor):
#   def __PrintMessageCommentLines(self, message_type):
#   def __PrintFieldDescription(self, description):
#   def __PrintFields(self, fields):
#   def PrintMessage(self, message_type):
#   def PrintCustomJsonMapping(self, mapping_lines):
#   def __init__(self, printer):
#   def __PrintClassSeparator(self):
#   def __PrintEnumDocstringLines(self, enum_type):
#   def PrintEnum(self, enum_type):
#   def __PrintAdditionalImports(self, imports):
#   def PrintPreamble(self, package, version, file_descriptor):
#   def __PrintMessageDocstringLines(self, message_type):
#   def PrintMessage(self, message_type):
#   def PrintCustomJsonMapping(self, mapping):
# def _PrintEnums(proto_printer, enum_types):
# def _PrintMessages(proto_printer, message_list):
# def _PrintFields(fields, printer):
# _MESSAGE_FIELD_MAP = {
#     message_types.DateTimeMessage.definition_name(): message_types.DateTimeField,
# }


# Path: apitools/gen/command_registry.py
import logging
import textwrap
from protorpc import descriptor
from protorpc import messages
from apitools.gen import extended_descriptor

  def __PrintGetClient(self, printer):
    printer('def GetClientFromFlags():')
    with printer.Indent():
      printer('"""Return a client object, configured from flags."""')
      printer('log_request = FLAGS.log_request or FLAGS.log_request_response')
      printer('log_response = FLAGS.log_response or FLAGS.log_request_response')
      printer('api_endpoint = apitools_base.NormalizeApiEndpoint('
              'FLAGS.api_endpoint)')
      printer("additional_http_headers = dict(x.split('=', 1) for x in "
              "FLAGS.add_header)")
      printer('try:')
      with printer.Indent():
        printer('client = client_lib.%s(', self.__client_info.client_class_name)
        with printer.Indent(indent='    '):
          printer('api_endpoint, log_request=log_request,')
          printer('log_response=log_response,')
          printer('additional_http_headers=additional_http_headers)')
      printer('except apitools_base.CredentialsError as e:')
      with printer.Indent():
        printer("print 'Error creating credentials: %%s' %% e")
        printer('sys.exit(1)')
      printer('return client')
    printer()
    printer()

  def __PrintCommandDocstring(self, printer, command_info):
    with printer.CommentContext():
      for line in textwrap.wrap('"""%s' % command_info.description,
                                printer.CalculateWidth()):
        printer(line)

      extended_descriptor.PrintIndentedDescriptions(